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"The only difference with E2 is the question of the problem.. Vlad built a maze out of n rooms and n-1 bidirectional corridors. From any room u any other room v can be reached through a sequence of corridors. Thus, the room system forms an undirected tree. Vlad invited k friends to play a game with them. Vlad starts the game in the room 1 and wins if he reaches a room other than 1 , into which exactly one corridor leads. Friends are placed in the maze: the friend with number i is in the room x_i , and no two friends are in the same room (that is, x_i neq x_j for all i neq j ). Friends win if one of them meets Vlad in any room or corridor before he wins. For one unit of time, each participant of the game can go through one corridor. All participants move at the same time. Participants may not move. Each room can fit all participants at the same time. Friends know the plan of a maze and intend to win. Vlad is a bit afraid of their ardor. Determine if he can guarantee victory (i.e. can he win in any way friends play). In other words, determine if there is such a sequence of Vlad's moves that lets Vlad win in any way friends play. The first line of the input contains an integer t ( 1 <= t <= 10^4 ) -- the number of test cases in the input. The input contains an empty string before each test case. The first line of the test case contains two numbers n and k ( 1 <= k < n <= 2 cdot 10^5 ) -- the number of rooms and friends, respectively. The next line of the test case contains k integers x_1, x_2, ... , x_k ( 2 <= x_i <= n ) -- numbers of rooms with friends. All x_i are different. The next n-1 lines contain descriptions of the corridors, two numbers per line v_j and u_j ( 1 <= u_j, v_j <= n ) -- numbers of rooms that connect the j corridor. All corridors are bidirectional. From any room, you can go to any other "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
136949941 |
ssvb |
E1 |
Nov. 25, 2021, 11:25 p.m. |
OK |
D |
TESTS |
14 |
249 |
33075200 |
|
1700 |
136982868 |
wangyian2022 |
E1 |
Nov. 26, 2021, 9:39 a.m. |
OK |
GNU C++14 |
TESTS |
14 |
30 |
9523200 |
|
1700 |
136957693 |
Bakti-Tuymehan-abai-2025 |
E1 |
Nov. 26, 2021, 3:29 a.m. |
OK |
GNU C++14 |
TESTS |
14 |
30 |
9523200 |
|
1700 |
137079955 |
XyzL |
E1 |
Nov. 27, 2021, 2:41 a.m. |
OK |
GNU C++14 |
TESTS |
14 |
62 |
17612800 |
|
1700 |
136976791 |
XyzL |
E1 |
Nov. 26, 2021, 8:24 a.m. |
OK |
GNU C++14 |
TESTS |
14 |
62 |
17612800 |
|
1700 |
136953003 |
et3_tsy |
E1 |
Nov. 26, 2021, 1:33 a.m. |
OK |
GNU C++14 |
TESTS |
14 |
78 |
10956800 |
|
1700 |
136986948 |
shengtongtong |
E1 |
Nov. 26, 2021, 10:37 a.m. |
OK |
GNU C++14 |
TESTS |
14 |
109 |
7987200 |
|
1700 |
136956279 |
Pepsi__Cola |
E1 |
Nov. 26, 2021, 2:58 a.m. |
OK |
GNU C++14 |
TESTS |
14 |
124 |
10752000 |
|
1700 |
137036065 |
CCSU_Cola |
E1 |
Nov. 26, 2021, 1:09 p.m. |
OK |
GNU C++14 |
TESTS |
14 |
124 |
43520000 |
|
1700 |
136963515 |
y198 |
E1 |
Nov. 26, 2021, 5:29 a.m. |
OK |
GNU C++14 |
TESTS |
14 |
139 |
7168000 |
|
1700 |
137045159 |
_ParadoX |
E1 |
Nov. 26, 2021, 2:20 p.m. |
OK |
GNU C++14 |
TESTS |
14 |
139 |
8601600 |
|
1700 |
136968368 |
shiyandong |
E1 |
Nov. 26, 2021, 6:35 a.m. |
OK |
GNU C++17 |
TESTS |
14 |
109 |
10854400 |
|
1700 |
136977186 |
Feng_D |
E1 |
Nov. 26, 2021, 8:29 a.m. |
OK |
GNU C++17 |
TESTS |
14 |
124 |
7372800 |
|
1700 |
137088135 |
my_world_ending |
E1 |
Nov. 27, 2021, 5:15 a.m. |
OK |
GNU C++17 |
TESTS |
14 |
124 |
7475200 |
|
1700 |
136974375 |
zhangpangpang |
E1 |
Nov. 26, 2021, 7:54 a.m. |
OK |
GNU C++17 |
TESTS |
14 |
124 |
9011200 |
|
1700 |
136971323 |
dargoncat |
E1 |
Nov. 26, 2021, 7:12 a.m. |
OK |
GNU C++17 |
TESTS |
14 |
124 |
9523200 |
|
1700 |
136965413 |
dargoncat |
E1 |
Nov. 26, 2021, 5:56 a.m. |
OK |
GNU C++17 |
TESTS |
14 |
124 |
9523200 |
|
1700 |
136979541 |
Ayanoto |
E1 |
Nov. 26, 2021, 8:57 a.m. |
OK |
GNU C++17 |
TESTS |
14 |
124 |
14540800 |
|
1700 |
136984852 |
sssyh |
E1 |
Nov. 26, 2021, 10:08 a.m. |
OK |
GNU C++17 |
TESTS |
14 |
124 |
14745600 |
|
1700 |
136982217 |
imagine7 |
E1 |
Nov. 26, 2021, 9:31 a.m. |
OK |
GNU C++17 |
TESTS |
14 |
124 |
15155200 |
|
1700 |
136986883 |
Ayanoto |
E1 |
Nov. 26, 2021, 10:36 a.m. |
OK |
GNU C++17 |
TESTS |
14 |
124 |
16896000 |
|
1700 |
136965084 |
nagisa2333 |
E1 |
Nov. 26, 2021, 5:51 a.m. |
OK |
GNU C++17 (64) |
TESTS |
14 |
124 |
7475200 |
|
1700 |
136982405 |
akshaykhandelwal |
E1 |
Nov. 26, 2021, 9:33 a.m. |
OK |
GNU C++17 (64) |
TESTS |
14 |
124 |
10240000 |
|
1700 |
136943074 |
ale_naser_pastoriza |
E1 |
Nov. 25, 2021, 7:51 p.m. |
OK |
GNU C++17 (64) |
TESTS |
14 |
124 |
10752000 |
|
1700 |
137053472 |
Isreal |
E1 |
Nov. 26, 2021, 3:54 p.m. |
OK |
GNU C++17 (64) |
TESTS |
14 |
124 |
11673600 |
|
1700 |
136944305 |
kushagra3288 |
E1 |
Nov. 25, 2021, 8:17 p.m. |
OK |
GNU C++17 (64) |
TESTS |
14 |
124 |
12185600 |
|
1700 |
136983481 |
Elias_Obeid |
E1 |
Nov. 26, 2021, 9:48 a.m. |
OK |
GNU C++17 (64) |
TESTS |
14 |
124 |
13312000 |
|
1700 |
136986544 |
harshavardhan0512 |
E1 |
Nov. 26, 2021, 10:32 a.m. |
OK |
GNU C++17 (64) |
TESTS |
14 |
124 |
13516800 |
|
1700 |
136981775 |
AkaMG |
E1 |
Nov. 26, 2021, 9:25 a.m. |
OK |
GNU C++17 (64) |
TESTS |
14 |
124 |
13516800 |
|
1700 |
136977553 |
prasantkpatel |
E1 |
Nov. 26, 2021, 8:33 a.m. |
OK |
GNU C++17 (64) |
TESTS |
14 |
124 |
13516800 |
|
1700 |
136948327 |
Divya2018 |
E1 |
Nov. 25, 2021, 10:10 p.m. |
OK |
GNU C++17 (64) |
TESTS |
14 |
139 |
10752000 |
|
1700 |
136963298 |
_elgir |
E1 |
Nov. 26, 2021, 5:27 a.m. |
OK |
GNU C++20 (64) |
TESTS |
14 |
77 |
7475200 |
|
1700 |
136966826 |
AC_Mikoto |
E1 |
Nov. 26, 2021, 6:16 a.m. |
OK |
GNU C++20 (64) |
TESTS |
14 |
78 |
8294400 |
|
1700 |
136959850 |
Dog_food_is_me |
E1 |
Nov. 26, 2021, 4:17 a.m. |
OK |
GNU C++20 (64) |
TESTS |
14 |
93 |
12390400 |
|
1700 |
137061312 |
ahmet23 |
E1 |
Nov. 26, 2021, 5:42 p.m. |
OK |
GNU C++20 (64) |
TESTS |
14 |
93 |
13312000 |
|
1700 |
136948934 |
Mahmoud-warrak |
E1 |
Nov. 25, 2021, 10:35 p.m. |
OK |
GNU C++20 (64) |
TESTS |
14 |
108 |
16384000 |
|
1700 |
136973701 |
xudian |
E1 |
Nov. 26, 2021, 7:44 a.m. |
OK |
GNU C++20 (64) |
TESTS |
14 |
109 |
10035200 |
|
1700 |
136963838 |
AssCumDoor |
E1 |
Nov. 26, 2021, 5:33 a.m. |
OK |
GNU C++20 (64) |
TESTS |
14 |
109 |
10035200 |
|
1700 |
136956328 |
Xhnxhn |
E1 |
Nov. 26, 2021, 2:59 a.m. |
OK |
GNU C++20 (64) |
TESTS |
14 |
109 |
10854400 |
|
1700 |
136957174 |
jdurie |
E1 |
Nov. 26, 2021, 3:19 a.m. |
OK |
GNU C++20 (64) |
TESTS |
14 |
109 |
14745600 |
|
1700 |
136938947 |
dushenkov |
E1 |
Nov. 25, 2021, 6:41 p.m. |
OK |
GNU C++20 (64) |
TESTS |
14 |
109 |
15462400 |
|
1700 |
137077374 |
0x3F |
E1 |
Nov. 27, 2021, 1:29 a.m. |
OK |
Go |
TESTS |
14 |
373 |
45260800 |
|
1700 |
136950522 |
sarthakmanna |
E1 |
Nov. 25, 2021, 11:55 p.m. |
OK |
Java 11 |
TESTS |
14 |
482 |
65024000 |
|
1700 |
136943516 |
dkkv0000 |
E1 |
Nov. 25, 2021, 8:01 p.m. |
OK |
Java 11 |
TESTS |
14 |
530 |
35737600 |
|
1700 |
136948018 |
_Body |
E1 |
Nov. 25, 2021, 9:58 p.m. |
OK |
Java 11 |
TESTS |
14 |
592 |
40140800 |
|
1700 |
136976255 |
SaberXpro |
E1 |
Nov. 26, 2021, 8:18 a.m. |
OK |
Java 11 |
TESTS |
14 |
670 |
58572800 |
|
1700 |
136941446 |
ssk4988 |
E1 |
Nov. 25, 2021, 7:21 p.m. |
OK |
Java 11 |
TESTS |
14 |
685 |
63283200 |
|
1700 |
137084220 |
sumitchavan |
E1 |
Nov. 27, 2021, 4:14 a.m. |
OK |
Java 11 |
TESTS |
14 |
717 |
75059200 |
|
1700 |
137029001 |
solo07 |
E1 |
Nov. 26, 2021, 12:48 p.m. |
OK |
Java 11 |
TESTS |
14 |
748 |
49561600 |
|
1700 |
137027180 |
MrOtter |
E1 |
Nov. 26, 2021, 12:42 p.m. |
OK |
Java 11 |
TESTS |
14 |
810 |
40038400 |
|
1700 |
136949554 |
Toinfinity |
E1 |
Nov. 25, 2021, 11:03 p.m. |
OK |
Java 11 |
TESTS |
14 |
858 |
83148800 |
|
1700 |
136972224 |
BiggEr. |
E1 |
Nov. 26, 2021, 7:24 a.m. |
OK |
Java 11 |
TESTS |
14 |
951 |
185958400 |
|
1700 |
137055312 |
ChiMasterBing |
E1 |
Nov. 26, 2021, 4:18 p.m. |
OK |
Java 8 |
TESTS |
14 |
468 |
50995200 |
|
1700 |
136946671 |
invincible777 |
E1 |
Nov. 25, 2021, 9:14 p.m. |
OK |
Java 8 |
TESTS |
14 |
514 |
55808000 |
|
1700 |
136979445 |
Akram-Adel |
E1 |
Nov. 26, 2021, 8:55 a.m. |
OK |
Java 8 |
TESTS |
14 |
546 |
45260800 |
|
1700 |
136979971 |
ruchir28 |
E1 |
Nov. 26, 2021, 9:02 a.m. |
OK |
Java 8 |
TESTS |
14 |
560 |
46694400 |
|
1700 |
137080848 |
GoldenShadow |
E1 |
Nov. 27, 2021, 3:01 a.m. |
OK |
Java 8 |
TESTS |
14 |
561 |
36044800 |
|
1700 |
136964308 |
dawud |
E1 |
Nov. 26, 2021, 5:39 a.m. |
OK |
Java 8 |
TESTS |
14 |
576 |
69120000 |
|
1700 |
137038747 |
RonWonWon |
E1 |
Nov. 26, 2021, 1:15 p.m. |
OK |
Java 8 |
TESTS |
14 |
607 |
105472000 |
|
1700 |
137069567 |
pras7946 |
E1 |
Nov. 26, 2021, 8:14 p.m. |
OK |
Java 8 |
TESTS |
14 |
935 |
69529600 |
|
1700 |
137046319 |
zimuqin |
E1 |
Nov. 26, 2021, 2:31 p.m. |
OK |
Java 8 |
TESTS |
14 |
1138 |
133632000 |
|
1700 |
137047713 |
zimuqin |
E1 |
Nov. 26, 2021, 2:45 p.m. |
OK |
Java 8 |
TESTS |
14 |
1184 |
133632000 |
|
1700 |
136979155 |
no_ac_no_sleep |
E1 |
Nov. 26, 2021, 8:52 a.m. |
OK |
MS C++ 2017 |
TESTS |
14 |
483 |
14028800 |
|
1700 |
136943179 |
AbnerShen |
E1 |
Nov. 25, 2021, 7:53 p.m. |
OK |
PyPy 3 |
TESTS |
14 |
545 |
31948800 |
|
1700 |
136936018 |
Greyhound |
E1 |
Nov. 25, 2021, 6:01 p.m. |
OK |
PyPy 3 |
TESTS |
14 |
592 |
57139200 |
|
1700 |
136969186 |
Bambam_Shivam |
E1 |
Nov. 26, 2021, 6:46 a.m. |
OK |
PyPy 3 |
TESTS |
14 |
748 |
32665600 |
|
1700 |
137079248 |
wolfram_ |
E1 |
Nov. 27, 2021, 2:25 a.m. |
OK |
PyPy 3 |
TESTS |
14 |
826 |
239923200 |
|
1700 |
136957213 |
wwwwzhh |
E1 |
Nov. 26, 2021, 3:20 a.m. |
OK |
PyPy 3 |
TESTS |
14 |
842 |
46284800 |
|
1700 |
136939789 |
lebron87 |
E1 |
Nov. 25, 2021, 6:54 p.m. |
OK |
PyPy 3 |
TESTS |
14 |
888 |
34816000 |
|
1700 |
136939307 |
lebron87 |
E1 |
Nov. 25, 2021, 6:47 p.m. |
OK |
PyPy 3 |
TESTS |
14 |
904 |
35123200 |
|
1700 |
136938945 |
lebron87 |
E1 |
Nov. 25, 2021, 6:41 p.m. |
OK |
PyPy 3 |
TESTS |
14 |
982 |
50380800 |
|
1700 |
136939096 |
lebron87 |
E1 |
Nov. 25, 2021, 6:43 p.m. |
OK |
PyPy 3 |
TESTS |
14 |
998 |
49664000 |
|
1700 |
136959779 |
whatshisbucket |
E1 |
Nov. 26, 2021, 4:15 a.m. |
OK |
PyPy 3 |
TESTS |
14 |
1247 |
75980800 |
|
1700 |
137075041 |
jjjjjj |
E1 |
Nov. 26, 2021, 11:39 p.m. |
OK |
PyPy 3-64 |
TESTS |
14 |
545 |
84480000 |
|
1700 |
136979202 |
laplce |
E1 |
Nov. 26, 2021, 8:52 a.m. |
OK |
PyPy 3-64 |
TESTS |
14 |
608 |
65126400 |
|
1700 |
136957763 |
RANK1ZEN |
E1 |
Nov. 26, 2021, 3:31 a.m. |
OK |
PyPy 3-64 |
TESTS |
14 |
655 |
42291200 |
|
1700 |
136957900 |
giant-mammoth |
E1 |
Nov. 26, 2021, 3:34 a.m. |
OK |
PyPy 3-64 |
TESTS |
14 |
717 |
79462400 |
|
1700 |
136940600 |
Malek_souissi |
E1 |
Nov. 25, 2021, 7:07 p.m. |
OK |
PyPy 3-64 |
TESTS |
14 |
748 |
47411200 |
|
1700 |
136988814 |
nicku123 |
E1 |
Nov. 26, 2021, 11:02 a.m. |
OK |
PyPy 3-64 |
TESTS |
14 |
748 |
58368000 |
|
1700 |
136940111 |
guineapig |
E1 |
Nov. 25, 2021, 6:59 p.m. |
OK |
PyPy 3-64 |
TESTS |
14 |
764 |
45260800 |
|
1700 |
137075003 |
jjjjjj |
E1 |
Nov. 26, 2021, 11:37 p.m. |
OK |
PyPy 3-64 |
TESTS |
14 |
764 |
81612800 |
|
1700 |
136958839 |
lemiao12 |
E1 |
Nov. 26, 2021, 3:55 a.m. |
OK |
PyPy 3-64 |
TESTS |
14 |
779 |
157900800 |
|
1700 |
136969203 |
Bambam_Shivam |
E1 |
Nov. 26, 2021, 6:46 a.m. |
OK |
PyPy 3-64 |
TESTS |
14 |
795 |
57958400 |
|
1700 |
136969164 |
Bambam_Shivam |
E1 |
Nov. 26, 2021, 6:46 a.m. |
OK |
Python 3 |
TESTS |
14 |
826 |
38707200 |
|
1700 |
136956229 |
armsusman |
E1 |
Nov. 26, 2021, 2:57 a.m. |
OK |
Python 3 |
TESTS |
14 |
1262 |
62259200 |
|
1700 |
136952146 |
Spheniscine |
E1 |
Nov. 26, 2021, 1:04 a.m. |
OK |
Rust |
TESTS |
14 |
124 |
25702400 |
|
1700 |
136972053 |
sansen |
E1 |
Nov. 26, 2021, 7:22 a.m. |
OK |
Rust |
TESTS |
14 |
139 |
51916800 |
|
1700 |
137058735 |
kobae964 |
E1 |
Nov. 26, 2021, 5:07 p.m. |
OK |
Rust |
TESTS |
14 |
343 |
82329600 |
|
1700 |
remove filters
Back to search problems