Solutions are presented as using the least memory and the fastest execution time. It also takes the top
10 most recent solutions from each language. If you want to limit to a specific index, click the
"Solved" button and go to that problem.
Problems
B'You are given an undirected connected graph, some vertices of which contain tokens and/or bonuses. Consider a game involving one player -- you. You can move tokens according to the following rules: You can use different bonuses in any order. The same bonus can be used an unlimited number of times. Bonuses do not move during the game. There can be several tokens in one vertex at the same time, but initially there is no more than one token in each vertex. The vertex with number 1 is the finish vertex, and your task is to determine whether it is possible to hit it with any token by making turns with the tiles according to the rules described above. If a token is initially located at the vertex of 1 , then the game is considered already won. The first line of input data contains a single integer t ( 1 <= t <= 10^4 ) -- number of test cases in the test. The descriptions of the test cases follow. The first line of the description of each test case contains two integers n and m ( 1 <= n <= 2 cdot 10^5 , 0 <= m <= 2 cdot 10^5 ) -- the number of vertices and edges in the graph, respectively. The second line of the description of each test case contains two integers p and b ( 1 <= p <= n, 0 <= b <= n ) -- the number of tokens and bonuses, respectively. The third line of the description of each test case contains p different integers from 1 to n -- the indices of the vertices in which the tokens are located. The fourth line of the description of each input data set contains b different integers from 1 to n -- the indices of the vertices in which the bonuses are located. Note that the value of b can be equal to 0 . In this case, this line is empty. There can be both a token and a bonus in one vertex at the same time. The next m lines of the description of each test case contain two integers u_i and v_i ( 1 <= u_i, v_i <= '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
190874201 |
Gassa |
G |
Jan. 27, 2023, 4:46 p.m. |
OK |
D |
TESTS |
46 |
405 |
24473600 |
|
|
190924608 |
V.L.Manaswini |
G |
Jan. 28, 2023, 4:47 a.m. |
OK |
GNU C++14 |
TESTS |
46 |
171 |
10854400 |
|
|
190883059 |
JoyGijk468 |
G |
Jan. 27, 2023, 5:21 p.m. |
OK |
GNU C++14 |
TESTS |
46 |
202 |
10240000 |
|
|
190920183 |
KurashinaAsuka |
G |
Jan. 28, 2023, 3:35 a.m. |
OK |
GNU C++14 |
TESTS |
46 |
202 |
10854400 |
|
|
190916381 |
GreatJMore |
G |
Jan. 28, 2023, 2:06 a.m. |
OK |
GNU C++14 |
TESTS |
46 |
202 |
11571200 |
|
|
190885791 |
Mina7akim |
G |
Jan. 27, 2023, 5:40 p.m. |
OK |
GNU C++14 |
TESTS |
46 |
202 |
19660800 |
|
|
190924603 |
LCqwq |
G |
Jan. 28, 2023, 4:46 a.m. |
OK |
GNU C++14 |
TESTS |
46 |
233 |
15052800 |
|
|
190880698 |
itz_archit |
G |
Jan. 27, 2023, 5:08 p.m. |
OK |
GNU C++14 |
TESTS |
46 |
233 |
17510400 |
|
|
190921492 |
pacha2880 |
G |
Jan. 28, 2023, 4:02 a.m. |
OK |
GNU C++14 |
TESTS |
46 |
249 |
22528000 |
|
|
190881266 |
Hex_10EFFB_ |
G |
Jan. 27, 2023, 5:11 p.m. |
OK |
GNU C++14 |
TESTS |
46 |
264 |
11161600 |
|
|
190888831 |
bary |
G |
Jan. 27, 2023, 6:04 p.m. |
OK |
GNU C++14 |
TESTS |
46 |
264 |
15155200 |
|
|
remove filters
Back to search problems