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 E1 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. They don't want to waste too much energy. They ask you to determine if they can win and if they can, what minimum number of friends must remain in the maze so that they can always catch Vlad. In other words, you need to determine the size of the minimum (by the number of elements) subset of friends who can catch Vlad or say that such a subset does not exist. 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 ) xe2"... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
136982885 |
wangyian2022 |
E2 |
Nov. 26, 2021, 9:39 a.m. |
OK |
GNU C++14 |
TESTS |
14 |
15 |
10956800 |
|
2000 |
136957729 |
Bakti-Tuymehan-abai-2025 |
E2 |
Nov. 26, 2021, 3:30 a.m. |
OK |
GNU C++14 |
TESTS |
14 |
15 |
10956800 |
|
2000 |
136953210 |
et3_tsy |
E2 |
Nov. 26, 2021, 1:39 a.m. |
OK |
GNU C++14 |
TESTS |
14 |
46 |
16896000 |
|
2000 |
137079968 |
XyzL |
E2 |
Nov. 27, 2021, 2:42 a.m. |
OK |
GNU C++14 |
TESTS |
14 |
61 |
23552000 |
|
2000 |
136978605 |
XyzL |
E2 |
Nov. 26, 2021, 8:45 a.m. |
OK |
GNU C++14 |
TESTS |
14 |
61 |
23552000 |
|
2000 |
136986727 |
shengtongtong |
E2 |
Nov. 26, 2021, 10:34 a.m. |
OK |
GNU C++14 |
TESTS |
14 |
109 |
7987200 |
|
2000 |
136973066 |
AuDragon |
E2 |
Nov. 26, 2021, 7:35 a.m. |
OK |
GNU C++14 |
TESTS |
14 |
109 |
28876800 |
|
2000 |
137048944 |
1884613kjh |
E2 |
Nov. 26, 2021, 2:58 p.m. |
OK |
GNU C++14 |
TESTS |
14 |
124 |
8806400 |
|
2000 |
136960955 |
freopen_ |
E2 |
Nov. 26, 2021, 4:40 a.m. |
OK |
GNU C++14 |
TESTS |
14 |
124 |
13209600 |
|
2000 |
137082196 |
anixai |
E2 |
Nov. 27, 2021, 3:31 a.m. |
OK |
GNU C++14 |
TESTS |
14 |
139 |
11980800 |
|
2000 |
136982230 |
imagine7 |
E2 |
Nov. 26, 2021, 9:31 a.m. |
OK |
GNU C++17 |
TESTS |
14 |
109 |
15257600 |
|
2000 |
136984376 |
Ayanoto |
E2 |
Nov. 26, 2021, 10:01 a.m. |
OK |
GNU C++17 |
TESTS |
14 |
109 |
19353600 |
|
2000 |
136946865 |
rspr |
E2 |
Nov. 25, 2021, 9:20 p.m. |
OK |
GNU C++17 |
TESTS |
14 |
124 |
13516800 |
|
2000 |
136957380 |
Bakti-Tuymehan-abai-2025 |
E2 |
Nov. 26, 2021, 3:23 a.m. |
OK |
GNU C++17 |
TESTS |
14 |
124 |
14336000 |
|
2000 |
136986719 |
Ayanoto |
E2 |
Nov. 26, 2021, 10:34 a.m. |
OK |
GNU C++17 |
TESTS |
14 |
124 |
18227200 |
|
2000 |
137039892 |
shroud777 |
E2 |
Nov. 26, 2021, 1:35 p.m. |
OK |
GNU C++17 |
TESTS |
14 |
124 |
18636800 |
|
2000 |
136958980 |
Yogi79 |
E2 |
Nov. 26, 2021, 3:58 a.m. |
OK |
GNU C++17 |
TESTS |
14 |
139 |
10956800 |
|
2000 |
136960657 |
Ash_Dr |
E2 |
Nov. 26, 2021, 4:34 a.m. |
OK |
GNU C++17 |
TESTS |
14 |
139 |
11571200 |
|
2000 |
136970485 |
jtrh |
E2 |
Nov. 26, 2021, 7:02 a.m. |
OK |
GNU C++17 |
TESTS |
14 |
139 |
11980800 |
|
2000 |
136958428 |
all0fme |
E2 |
Nov. 26, 2021, 3:46 a.m. |
OK |
GNU C++17 |
TESTS |
14 |
139 |
18432000 |
|
2000 |
136964890 |
shiro53 |
E2 |
Nov. 26, 2021, 5:47 a.m. |
OK |
GNU C++17 (64) |
TESTS |
14 |
124 |
12800000 |
|
2000 |
136957956 |
dgupta0812 |
E2 |
Nov. 26, 2021, 3:35 a.m. |
OK |
GNU C++17 (64) |
TESTS |
14 |
124 |
19046400 |
|
2000 |
136945545 |
kushagra3288 |
E2 |
Nov. 25, 2021, 8:43 p.m. |
OK |
GNU C++17 (64) |
TESTS |
14 |
139 |
13209600 |
|
2000 |
136984877 |
smrandom |
E2 |
Nov. 26, 2021, 10:08 a.m. |
OK |
GNU C++17 (64) |
TESTS |
14 |
139 |
15052800 |
|
2000 |
137090278 |
0_5 |
E2 |
Nov. 27, 2021, 5:41 a.m. |
OK |
GNU C++17 (64) |
TESTS |
14 |
139 |
20070400 |
|
2000 |
136977469 |
SouIman |
E2 |
Nov. 26, 2021, 8:32 a.m. |
OK |
GNU C++17 (64) |
TESTS |
14 |
139 |
21811200 |
|
2000 |
136988961 |
qpEDop_MuXauJloBu4 |
E2 |
Nov. 26, 2021, 11:04 a.m. |
OK |
GNU C++17 (64) |
TESTS |
14 |
140 |
10547200 |
|
2000 |
136963540 |
scau_y |
E2 |
Nov. 26, 2021, 5:29 a.m. |
OK |
GNU C++17 (64) |
TESTS |
14 |
140 |
14028800 |
|
2000 |
136974382 |
shubhamgrg1000 |
E2 |
Nov. 26, 2021, 7:54 a.m. |
OK |
GNU C++17 (64) |
TESTS |
14 |
140 |
18739200 |
|
2000 |
136960731 |
isheoran |
E2 |
Nov. 26, 2021, 4:35 a.m. |
OK |
GNU C++17 (64) |
TESTS |
14 |
140 |
18841600 |
|
2000 |
136939278 |
Cleanblue |
E2 |
Nov. 25, 2021, 6:46 p.m. |
OK |
GNU C++20 (64) |
TESTS |
14 |
108 |
16281600 |
|
2000 |
137087398 |
GoracioNewport |
E2 |
Nov. 27, 2021, 5:05 a.m. |
OK |
GNU C++20 (64) |
TESTS |
14 |
108 |
25190400 |
|
2000 |
136989030 |
axe98 |
E2 |
Nov. 26, 2021, 11:05 a.m. |
OK |
GNU C++20 (64) |
TESTS |
14 |
109 |
12185600 |
|
2000 |
136941244 |
arnav2004 |
E2 |
Nov. 25, 2021, 7:18 p.m. |
OK |
GNU C++20 (64) |
TESTS |
14 |
109 |
12185600 |
|
2000 |
136955061 |
I_francis |
E2 |
Nov. 26, 2021, 2:30 a.m. |
OK |
GNU C++20 (64) |
TESTS |
14 |
109 |
12697600 |
|
2000 |
136966147 |
segment-tree-enjoyer |
E2 |
Nov. 26, 2021, 6:07 a.m. |
OK |
GNU C++20 (64) |
TESTS |
14 |
109 |
14745600 |
|
2000 |
136979819 |
ARINOOR |
E2 |
Nov. 26, 2021, 9 a.m. |
OK |
GNU C++20 (64) |
TESTS |
14 |
109 |
14848000 |
|
2000 |
136974690 |
Joseph1314 |
E2 |
Nov. 26, 2021, 7:58 a.m. |
OK |
GNU C++20 (64) |
TESTS |
14 |
109 |
16281600 |
|
2000 |
136957724 |
t3a |
E2 |
Nov. 26, 2021, 3:30 a.m. |
OK |
GNU C++20 (64) |
TESTS |
14 |
109 |
16486400 |
|
2000 |
136959987 |
Dog_food_is_me |
E2 |
Nov. 26, 2021, 4:20 a.m. |
OK |
GNU C++20 (64) |
TESTS |
14 |
109 |
23040000 |
|
2000 |
137077492 |
0x3F |
E2 |
Nov. 27, 2021, 1:33 a.m. |
OK |
Go |
TESTS |
14 |
373 |
43622400 |
|
2000 |
137077395 |
0x3F |
E2 |
Nov. 27, 2021, 1:30 a.m. |
OK |
Go |
TESTS |
14 |
373 |
44646400 |
|
2000 |
136945169 |
dkkv0000 |
E2 |
Nov. 25, 2021, 8:34 p.m. |
OK |
Java 11 |
TESTS |
14 |
530 |
36864000 |
|
2000 |
136976176 |
SaberXpro |
E2 |
Nov. 26, 2021, 8:17 a.m. |
OK |
Java 11 |
TESTS |
14 |
639 |
62156800 |
|
2000 |
137084562 |
sumitchavan |
E2 |
Nov. 27, 2021, 4:21 a.m. |
OK |
Java 11 |
TESTS |
14 |
686 |
67993600 |
|
2000 |
136960062 |
Nicolas125841 |
E2 |
Nov. 26, 2021, 4:21 a.m. |
OK |
Java 11 |
TESTS |
14 |
701 |
60006400 |
|
2000 |
136951396 |
ssk4988 |
E2 |
Nov. 26, 2021, 12:37 a.m. |
OK |
Java 11 |
TESTS |
14 |
748 |
51712000 |
|
2000 |
136949750 |
Toinfinity |
E2 |
Nov. 25, 2021, 11:13 p.m. |
OK |
Java 11 |
TESTS |
14 |
841 |
83148800 |
|
2000 |
136946787 |
invincible777 |
E2 |
Nov. 25, 2021, 9:17 p.m. |
OK |
Java 8 |
TESTS |
14 |
545 |
55808000 |
|
2000 |
136981824 |
dawud |
E2 |
Nov. 26, 2021, 9:26 a.m. |
OK |
Java 8 |
TESTS |
14 |
904 |
162201600 |
|
2000 |
136956057 |
qing_lin |
E2 |
Nov. 26, 2021, 2:53 a.m. |
OK |
MS C++ 2017 |
TESTS |
14 |
421 |
14540800 |
|
2000 |
136948500 |
TribalGolem |
E2 |
Nov. 25, 2021, 10:17 p.m. |
OK |
PyPy 2 |
TESTS |
14 |
1435 |
35430400 |
|
2000 |
136945949 |
sushmanth.dampur8780 |
E2 |
Nov. 25, 2021, 8:54 p.m. |
OK |
PyPy 3 |
TESTS |
14 |
701 |
28160000 |
|
2000 |
136960827 |
wwwwzhh |
E2 |
Nov. 26, 2021, 4:37 a.m. |
OK |
PyPy 3 |
TESTS |
14 |
857 |
40345600 |
|
2000 |
136969382 |
Bambam_Shivam |
E2 |
Nov. 26, 2021, 6:48 a.m. |
OK |
PyPy 3 |
TESTS |
14 |
857 |
40960000 |
|
2000 |
136963314 |
whatshisbucket |
E2 |
Nov. 26, 2021, 5:27 a.m. |
OK |
PyPy 3 |
TESTS |
14 |
951 |
72089600 |
|
2000 |
136961328 |
whatshisbucket |
E2 |
Nov. 26, 2021, 4:46 a.m. |
OK |
PyPy 3 |
TESTS |
14 |
982 |
74137600 |
|
2000 |
136959739 |
whatshisbucket |
E2 |
Nov. 26, 2021, 4:15 a.m. |
OK |
PyPy 3 |
TESTS |
14 |
1262 |
68096000 |
|
2000 |
136979699 |
laplce |
E2 |
Nov. 26, 2021, 8:59 a.m. |
OK |
PyPy 3-64 |
TESTS |
14 |
623 |
48537600 |
|
2000 |
136944028 |
Malek_souissi |
E2 |
Nov. 25, 2021, 8:11 p.m. |
OK |
PyPy 3-64 |
TESTS |
14 |
685 |
67686400 |
|
2000 |
136970572 |
guineapig |
E2 |
Nov. 26, 2021, 7:03 a.m. |
OK |
PyPy 3-64 |
TESTS |
14 |
701 |
43827200 |
|
2000 |
137075080 |
jjjjjj |
E2 |
Nov. 26, 2021, 11:42 p.m. |
OK |
PyPy 3-64 |
TESTS |
14 |
701 |
123596800 |
|
2000 |
136985449 |
lemiao12 |
E2 |
Nov. 26, 2021, 10:16 a.m. |
OK |
PyPy 3-64 |
TESTS |
14 |
732 |
149094400 |
|
2000 |
137015901 |
nicku123 |
E2 |
Nov. 26, 2021, 12:08 p.m. |
OK |
PyPy 3-64 |
TESTS |
14 |
764 |
53248000 |
|
2000 |
136969399 |
Bambam_Shivam |
E2 |
Nov. 26, 2021, 6:49 a.m. |
OK |
PyPy 3-64 |
TESTS |
14 |
920 |
76595200 |
|
2000 |
137075109 |
jjjjjj |
E2 |
Nov. 26, 2021, 11:44 p.m. |
OK |
PyPy 3-64 |
TESTS |
14 |
920 |
123187200 |
|
2000 |
137074503 |
jjjjjj |
E2 |
Nov. 26, 2021, 11:07 p.m. |
OK |
PyPy 3-64 |
TESTS |
14 |
1013 |
128614400 |
|
2000 |
136969353 |
Bambam_Shivam |
E2 |
Nov. 26, 2021, 6:48 a.m. |
OK |
Python 3 |
TESTS |
14 |
1122 |
34099200 |
|
2000 |
136959207 |
Spheniscine |
E2 |
Nov. 26, 2021, 4:03 a.m. |
OK |
Rust |
TESTS |
14 |
109 |
25190400 |
|
2000 |
136971956 |
sansen |
E2 |
Nov. 26, 2021, 7:20 a.m. |
OK |
Rust |
TESTS |
14 |
140 |
51609600 |
|
2000 |
137060489 |
kobae964 |
E2 |
Nov. 26, 2021, 5:30 p.m. |
OK |
Rust |
TESTS |
14 |
389 |
88064000 |
|
2000 |
137060420 |
kobae964 |
E2 |
Nov. 26, 2021, 5:29 p.m. |
OK |
Rust |
TESTS |
14 |
389 |
88064000 |
|
2000 |
remove filters
Back to search problems