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"Alice got tired of playing the tag game by the usual rules so she offered Bob a little modification to it. Now the game should be played on an undirected rooted tree of n vertices. Vertex 1 is the root of the tree. Alice starts at vertex 1 and Bob starts at vertex x (x xe2 x80 x89 xe2 x89 xa0 xe2 x80 x891). The moves are made in turns, Bob goes first. In one move one can either stay at the current vertex or travel to the neighbouring one. The game ends when Alice goes to the same vertex where Bob is standing. Alice wants to minimize the total number of moves and Bob wants to maximize it. You should write a program which will determine how many moves will the game last. The first line contains two integer numbers n and x (2 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n xe2 x80 x89 xe2 x89 xa4 xe2 x80 x892 xc2 xb7105, 2 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89x xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n). Each of the next n xe2 x80 x89- xe2 x80 x891 lines contains two integer numbers a and b (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89a, xe2 x80 x89b xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n) -- edges of the tree. It is guaranteed that the edges form a valid tree. Print the total number of moves Alice and Bob will make. In the first example the tree looks like this: The red vertex is Alice's starting position, the blue one is Bob's. Bob will make the game run the longest by standing at the vertex 3 during all the game. So here are the moves: B: stay at vertex 3 A: go to vertex 2 B: stay at vertex 3 A: go to vertex 3 In the second example the tree looks like this: The moves in the optimal strategy are: B: go to vertex 3 A: go to vertex 2 B: go to vertex 4 A: go to vertex 3 B: stay at vertex 4 A: go to vertex 4 "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
27601243 |
nanae1914 |
C |
June 5, 2017, 9:59 p.m. |
OK |
D |
TESTS |
25 |
280 |
37888000 |
|
1700 |
28759879 |
ruban |
C |
July 21, 2017, 4:29 p.m. |
OK |
Delphi |
TESTS |
25 |
140 |
51200000 |
|
1700 |
27592253 |
sagiri_ |
C |
June 5, 2017, 4:08 p.m. |
OK |
FPC |
TESTS |
25 |
93 |
14438400 |
|
1700 |
27788920 |
1.o4 |
C |
June 15, 2017, 7:54 a.m. |
OK |
FPC |
TESTS |
25 |
108 |
11571200 |
|
1700 |
27590325 |
VladProg |
C |
June 5, 2017, 3:48 p.m. |
OK |
FPC |
TESTS |
25 |
124 |
10444800 |
|
1700 |
40994468 |
vjudge1 |
C |
July 31, 2018, 2:45 a.m. |
OK |
FPC |
TESTS |
25 |
124 |
14438400 |
|
1700 |
51965592 |
chaorenhaha |
C |
March 29, 2019, 9:44 a.m. |
OK |
FPC |
TESTS |
25 |
124 |
16384000 |
|
1700 |
40841558 |
chaorenhaha |
C |
July 27, 2018, 9:50 a.m. |
OK |
FPC |
TESTS |
25 |
124 |
24064000 |
|
1700 |
42797045 |
TShT |
C |
Sept. 12, 2018, 12:17 p.m. |
OK |
FPC |
TESTS |
25 |
124 |
104140800 |
|
1700 |
27594764 |
ndhp2000 |
C |
June 5, 2017, 4:38 p.m. |
OK |
FPC |
TESTS |
25 |
139 |
28160000 |
|
1700 |
40257744 |
chaorenhaha |
C |
July 13, 2018, 10:10 a.m. |
OK |
FPC |
TESTS |
25 |
140 |
14438400 |
|
1700 |
27713331 |
ditsing |
C |
June 11, 2017, 1:40 a.m. |
OK |
GNU C |
TESTS |
25 |
109 |
11980800 |
|
1700 |
27602705 |
rainboy |
C |
June 6, 2017, 1:15 a.m. |
OK |
GNU C |
TESTS |
25 |
155 |
21811200 |
|
1700 |
27784986 |
TSS_99 |
C |
June 15, 2017, 2:50 a.m. |
OK |
GNU C |
TESTS |
25 |
171 |
22630400 |
|
1700 |
27596183 |
Tgotp |
C |
June 5, 2017, 5 p.m. |
OK |
GNU C++ |
TESTS |
25 |
46 |
8908800 |
|
1700 |
27608696 |
AkaneSasu |
C |
June 6, 2017, 8:35 a.m. |
OK |
GNU C++ |
TESTS |
25 |
46 |
12595200 |
|
1700 |
27603308 |
jszyxw |
C |
June 6, 2017, 2:17 a.m. |
OK |
GNU C++ |
TESTS |
25 |
46 |
12800000 |
|
1700 |
28200076 |
zqh_wz |
C |
July 2, 2017, 12:29 a.m. |
OK |
GNU C++ |
TESTS |
25 |
46 |
14028800 |
|
1700 |
27591543 |
ACMLCZH |
C |
June 5, 2017, 4 p.m. |
OK |
GNU C++ |
TESTS |
25 |
46 |
14233600 |
|
1700 |
40653934 |
vjudge2 |
C |
July 23, 2018, 2:10 a.m. |
OK |
GNU C++ |
TESTS |
25 |
46 |
15257600 |
|
1700 |
35110016 |
vjudge2 |
C |
Feb. 10, 2018, 2:57 a.m. |
OK |
GNU C++ |
TESTS |
25 |
46 |
15667200 |
|
1700 |
35109016 |
vjudge2 |
C |
Feb. 10, 2018, 1:44 a.m. |
OK |
GNU C++ |
TESTS |
25 |
46 |
15667200 |
|
1700 |
35109755 |
vjudge3 |
C |
Feb. 10, 2018, 2:39 a.m. |
OK |
GNU C++ |
TESTS |
25 |
46 |
17305600 |
|
1700 |
27963914 |
strawberrry |
C |
June 22, 2017, 11:45 a.m. |
OK |
GNU C++ |
TESTS |
25 |
46 |
17305600 |
|
1700 |
50821936 |
ychokhani77 |
C |
March 5, 2019, 1:54 p.m. |
OK |
GNU C11 |
TESTS |
25 |
93 |
15974400 |
|
1700 |
68848193 |
Ghost_Dragon |
C |
Jan. 15, 2020, 8:05 a.m. |
OK |
GNU C++11 |
TESTS |
25 |
31 |
11161600 |
|
1700 |
57772391 |
Zed_knight |
C |
July 26, 2019, 1:37 a.m. |
OK |
GNU C++11 |
TESTS |
25 |
31 |
40243200 |
|
1700 |
27604201 |
g1n0st |
C |
June 6, 2017, 3:35 a.m. |
OK |
GNU C++11 |
TESTS |
25 |
46 |
8908800 |
|
1700 |
27631696 |
Anson529 |
C |
June 7, 2017, 11:42 a.m. |
OK |
GNU C++11 |
TESTS |
25 |
46 |
8908800 |
|
1700 |
27592543 |
pyop |
C |
June 5, 2017, 4:10 p.m. |
OK |
GNU C++11 |
TESTS |
25 |
46 |
8908800 |
|
1700 |
57448262 |
vjudge5 |
C |
July 21, 2019, 8:53 a.m. |
OK |
GNU C++11 |
TESTS |
25 |
46 |
10035200 |
|
1700 |
27603766 |
Mr.Mo |
C |
June 6, 2017, 2:59 a.m. |
OK |
GNU C++11 |
TESTS |
25 |
46 |
11776000 |
|
1700 |
57174229 |
luogu_bot1 |
C |
July 17, 2019, 4:49 a.m. |
OK |
GNU C++11 |
TESTS |
25 |
46 |
11776000 |
|
1700 |
58155217 |
luogu_bot5 |
C |
Aug. 2, 2019, 5:16 a.m. |
OK |
GNU C++11 |
TESTS |
25 |
46 |
11980800 |
|
1700 |
59948364 |
vjudge1 |
C |
Sept. 3, 2019, 1:42 p.m. |
OK |
GNU C++11 |
TESTS |
25 |
46 |
12595200 |
|
1700 |
62557920 |
Helman |
C |
Oct. 14, 2019, 11:09 a.m. |
OK |
GNU C++14 |
TESTS |
25 |
93 |
5836800 |
|
1700 |
41579882 |
yiqzq |
C |
Aug. 14, 2018, 7:32 a.m. |
OK |
GNU C++14 |
TESTS |
25 |
93 |
15155200 |
|
1700 |
41579861 |
yiqzq |
C |
Aug. 14, 2018, 7:31 a.m. |
OK |
GNU C++14 |
TESTS |
25 |
93 |
15155200 |
|
1700 |
41580059 |
yiqzq |
C |
Aug. 14, 2018, 7:36 a.m. |
OK |
GNU C++14 |
TESTS |
25 |
93 |
15155200 |
|
1700 |
41580099 |
yiqzq |
C |
Aug. 14, 2018, 7:37 a.m. |
OK |
GNU C++14 |
TESTS |
25 |
93 |
15974400 |
|
1700 |
41580124 |
yiqzq |
C |
Aug. 14, 2018, 7:38 a.m. |
OK |
GNU C++14 |
TESTS |
25 |
93 |
15974400 |
|
1700 |
45399738 |
vjudge3 |
C |
Nov. 7, 2018, 7:39 a.m. |
OK |
GNU C++14 |
TESTS |
25 |
108 |
12800000 |
|
1700 |
53702502 |
vjudge1 |
C |
May 3, 2019, 11:21 a.m. |
OK |
GNU C++14 |
TESTS |
25 |
108 |
16384000 |
|
1700 |
27608425 |
WillWang98 |
C |
June 6, 2017, 8:22 a.m. |
OK |
GNU C++14 |
TESTS |
25 |
109 |
6041600 |
|
1700 |
52308762 |
vjudge2 |
C |
April 4, 2019, 1:36 p.m. |
OK |
GNU C++14 |
TESTS |
25 |
109 |
9932800 |
|
1700 |
51119097 |
zcfinal |
C |
March 10, 2019, 8:22 a.m. |
OK |
GNU C++17 |
TESTS |
25 |
93 |
13824000 |
|
1700 |
51115796 |
nancheng58 |
C |
March 10, 2019, 6:50 a.m. |
OK |
GNU C++17 |
TESTS |
25 |
108 |
12800000 |
|
1700 |
51129612 |
vjudge2 |
C |
March 10, 2019, 1:12 p.m. |
OK |
GNU C++17 |
TESTS |
25 |
108 |
13824000 |
|
1700 |
52225263 |
yinky |
C |
April 2, 2019, 9:03 a.m. |
OK |
GNU C++17 |
TESTS |
25 |
109 |
12185600 |
|
1700 |
56503850 |
vjudge5 |
C |
July 4, 2019, 7:33 a.m. |
OK |
GNU C++17 |
TESTS |
25 |
109 |
14643200 |
|
1700 |
69028524 |
vjudge1 |
C |
Jan. 18, 2020, 7:39 a.m. |
OK |
GNU C++17 |
TESTS |
25 |
109 |
16793600 |
|
1700 |
58063498 |
vjudge1 |
C |
July 31, 2019, 8:12 a.m. |
OK |
GNU C++17 |
TESTS |
25 |
109 |
19968000 |
|
1700 |
56783917 |
emmmmmm |
C |
July 10, 2019, 7:31 a.m. |
OK |
GNU C++17 |
TESTS |
25 |
124 |
6656000 |
|
1700 |
52668371 |
HIT_Attacker |
C |
April 13, 2019, 6:08 a.m. |
OK |
GNU C++17 |
TESTS |
25 |
124 |
11980800 |
|
1700 |
51116943 |
vjudge4 |
C |
March 10, 2019, 7:25 a.m. |
OK |
GNU C++17 |
TESTS |
25 |
124 |
12800000 |
|
1700 |
67600322 |
rnazmo |
C |
Dec. 25, 2019, 11:40 a.m. |
OK |
Go |
TESTS |
25 |
140 |
29388800 |
|
1700 |
45773652 |
Marii |
C |
Nov. 15, 2018, 3:50 p.m. |
OK |
Go |
TESTS |
25 |
358 |
18841600 |
|
1700 |
30365186 |
sl0th |
C |
Sept. 15, 2017, 2:26 p.m. |
OK |
Haskell |
TESTS |
25 |
748 |
74752000 |
|
1700 |
30364959 |
sl0th |
C |
Sept. 15, 2017, 2:14 p.m. |
OK |
Haskell |
TESTS |
25 |
842 |
111513600 |
|
1700 |
69231642 |
ankyy_0103 |
C |
Jan. 21, 2020, 9:44 a.m. |
OK |
Java 11 |
TESTS |
25 |
608 |
35840000 |
|
1700 |
27587783 |
uwi |
C |
June 5, 2017, 3:27 p.m. |
OK |
Java 8 |
TESTS |
25 |
202 |
4505600 |
|
1700 |
27617952 |
prashanth_rebala |
C |
June 6, 2017, 4:15 p.m. |
OK |
Java 8 |
TESTS |
25 |
202 |
17100800 |
|
1700 |
27590353 |
hiromi_ayase |
C |
June 5, 2017, 3:49 p.m. |
OK |
Java 8 |
TESTS |
25 |
218 |
3993600 |
|
1700 |
27588263 |
MazzForces |
C |
June 5, 2017, 3:31 p.m. |
OK |
Java 8 |
TESTS |
25 |
249 |
17510400 |
|
1700 |
27588993 |
fetetriste |
C |
June 5, 2017, 3:37 p.m. |
OK |
Java 8 |
TESTS |
25 |
280 |
2355200 |
|
1700 |
45576947 |
Jarik |
C |
Nov. 11, 2018, 9:28 p.m. |
OK |
Java 8 |
TESTS |
25 |
280 |
17715200 |
|
1700 |
45577000 |
Jarik |
C |
Nov. 11, 2018, 9:32 p.m. |
OK |
Java 8 |
TESTS |
25 |
296 |
17715200 |
|
1700 |
29246891 |
birlax |
C |
Aug. 6, 2017, 6:08 p.m. |
OK |
Java 8 |
TESTS |
25 |
327 |
27340800 |
|
1700 |
38719866 |
Taran_1407 |
C |
May 29, 2018, 1:31 p.m. |
OK |
Java 8 |
TESTS |
25 |
343 |
23347200 |
|
1700 |
27606048 |
Maulik_Patel |
C |
June 6, 2017, 5:57 a.m. |
OK |
Java 8 |
TESTS |
25 |
358 |
44441600 |
|
1700 |
27593438 |
serejkee |
C |
June 5, 2017, 4:21 p.m. |
OK |
Kotlin |
TESTS |
25 |
638 |
59289600 |
|
1700 |
27593316 |
hamayanhamayan |
C |
June 5, 2017, 4:19 p.m. |
OK |
Kotlin |
TESTS |
25 |
639 |
123699200 |
|
1700 |
27593548 |
leign |
C |
June 5, 2017, 4:22 p.m. |
OK |
Mono C# |
TESTS |
25 |
420 |
24780800 |
|
1700 |
27631571 |
erkebulan69 |
C |
June 7, 2017, 11:35 a.m. |
OK |
Mono C# |
TESTS |
25 |
623 |
42700800 |
|
1700 |
27619149 |
og.kostya |
C |
June 6, 2017, 5:36 p.m. |
OK |
MS C# |
TESTS |
25 |
140 |
27852800 |
|
1700 |
27607556 |
fr0st |
C |
June 6, 2017, 7:27 a.m. |
OK |
MS C# |
TESTS |
25 |
405 |
28979200 |
|
1700 |
28209150 |
kawazaki |
C |
July 2, 2017, 11:26 a.m. |
OK |
MS C# |
TESTS |
25 |
405 |
33177600 |
|
1700 |
27627212 |
artsin666 |
C |
June 7, 2017, 7:09 a.m. |
OK |
MS C# |
TESTS |
25 |
436 |
35225600 |
|
1700 |
27590317 |
azukun |
C |
June 5, 2017, 3:48 p.m. |
OK |
MS C# |
TESTS |
25 |
452 |
33177600 |
|
1700 |
27627142 |
artsin666 |
C |
June 7, 2017, 7:05 a.m. |
OK |
MS C# |
TESTS |
25 |
467 |
35225600 |
|
1700 |
52327724 |
vjudge2 |
C |
April 5, 2019, 2:30 a.m. |
OK |
MS C++ |
TESTS |
25 |
93 |
6656000 |
|
1700 |
40667390 |
vjudge2 |
C |
July 23, 2018, 10:40 a.m. |
OK |
MS C++ |
TESTS |
25 |
93 |
11980800 |
|
1700 |
40659545 |
vjudge3 |
C |
July 23, 2018, 6:24 a.m. |
OK |
MS C++ |
TESTS |
25 |
93 |
18432000 |
|
1700 |
35434877 |
scorpiowf |
C |
Feb. 18, 2018, 2:38 a.m. |
OK |
MS C++ |
TESTS |
25 |
124 |
12492800 |
|
1700 |
56502404 |
vjudge1 |
C |
July 4, 2019, 6:57 a.m. |
OK |
MS C++ |
TESTS |
25 |
140 |
9113600 |
|
1700 |
56670029 |
vjudge3 |
C |
July 7, 2019, 12:42 p.m. |
OK |
MS C++ |
TESTS |
25 |
140 |
15257600 |
|
1700 |
58127671 |
vjudge5 |
C |
Aug. 1, 2019, 1:10 p.m. |
OK |
MS C++ |
TESTS |
25 |
140 |
16896000 |
|
1700 |
57433071 |
vjudge1 |
C |
July 21, 2019, 2:54 a.m. |
OK |
MS C++ |
TESTS |
25 |
155 |
15257600 |
|
1700 |
52343004 |
vjudge5 |
C |
April 5, 2019, 11:23 a.m. |
OK |
MS C++ |
TESTS |
25 |
155 |
16076800 |
|
1700 |
28942805 |
nka_kun |
C |
July 28, 2017, 4:43 a.m. |
OK |
MS C++ |
TESTS |
25 |
155 |
18124800 |
|
1700 |
63693225 |
HishamDroubi |
C |
Oct. 29, 2019, 4:01 a.m. |
OK |
MS C++ 2017 |
TESTS |
25 |
405 |
12083200 |
|
1700 |
53969960 |
Still_Theory |
C |
May 10, 2019, 8:13 p.m. |
OK |
MS C++ 2017 |
TESTS |
25 |
421 |
16793600 |
|
1700 |
67939402 |
lgio |
C |
Dec. 29, 2019, 10:52 p.m. |
OK |
MS C++ 2017 |
TESTS |
25 |
514 |
10649600 |
|
1700 |
28291375 |
BenL |
C |
July 5, 2017, 12:40 a.m. |
OK |
PyPy 2 |
TESTS |
25 |
732 |
45977600 |
|
1700 |
27697546 |
abhigupta4 |
C |
June 9, 2017, 11:14 p.m. |
OK |
PyPy 2 |
TESTS |
25 |
872 |
17817600 |
|
1700 |
40108648 |
jooj |
C |
July 9, 2018, 10:11 a.m. |
OK |
PyPy 2 |
TESTS |
25 |
889 |
21811200 |
|
1700 |
39223774 |
YESMAths |
C |
June 13, 2018, 6:04 p.m. |
OK |
PyPy 2 |
TESTS |
25 |
936 |
65433600 |
|
1700 |
27784941 |
Avalanche |
C |
June 15, 2017, 2:44 a.m. |
OK |
PyPy 2 |
TESTS |
25 |
966 |
17817600 |
|
1700 |
27594991 |
tmarice |
C |
June 5, 2017, 4:41 p.m. |
OK |
PyPy 2 |
TESTS |
25 |
982 |
41062400 |
|
1700 |
51427608 |
r57shell |
C |
March 17, 2019, 8:22 p.m. |
OK |
PyPy 3 |
TESTS |
25 |
639 |
20684800 |
|
1700 |
65493767 |
PhilTheFish |
C |
Nov. 21, 2019, 3:45 p.m. |
OK |
PyPy 3 |
TESTS |
25 |
655 |
27238400 |
|
1700 |
50229004 |
Annvv |
C |
Feb. 20, 2019, 8:21 a.m. |
OK |
PyPy 3 |
TESTS |
25 |
732 |
32870400 |
|
1700 |
27600340 |
sas |
C |
June 5, 2017, 8:29 p.m. |
OK |
PyPy 3 |
TESTS |
25 |
919 |
37068800 |
|
1700 |
27682002 |
runar.hovland |
C |
June 9, 2017, 3:59 a.m. |
OK |
PyPy 3 |
TESTS |
25 |
935 |
32460800 |
|
1700 |
27592649 |
sas |
C |
June 5, 2017, 4:12 p.m. |
OK |
PyPy 3 |
TESTS |
25 |
998 |
37376000 |
|
1700 |
28291351 |
BenL |
C |
July 5, 2017, 12:38 a.m. |
OK |
PyPy 3 |
TESTS |
25 |
998 |
49049600 |
|
1700 |
29145155 |
williamyaoh |
C |
Aug. 3, 2017, 4:32 a.m. |
OK |
Rust |
TESTS |
25 |
155 |
14643200 |
|
1700 |
remove filters
Back to search problems