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 a tree consisting of n vertices (numbered from 1 to n). Initially all vertices are white. You have to process q queries of two different types: For each query of type 2 print the answer to it. Note that the queries are given in modified way. The first line contains two numbers n and q (3 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n, xe2 x80 x89q xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89106). Then n xe2 x80 x89- xe2 x80 x891 lines follow, each line containing two numbers xi and yi (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89xi xe2 x80 x89< xe2 x80 x89yi xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n) and representing the edge between vertices xi and yi. It is guaranteed that these edges form a tree. Then q lines follow. Each line contains two integers ti and zi, where ti is the type of ith query, and zi can be used to restore xi for this query in this way: you have to keep track of the answer to the last query of type 2 (let's call this answer last, and initially last xe2 x80 x89= xe2 x80 x890); then xi xe2 x80 x89= xe2 x80 x89(zi xe2 x80 x89+ xe2 x80 x89last) xe2 x80 x89mod xe2 x80 x89n xe2 x80 x89+ xe2 x80 x891. It is guaranteed that the first query is of type 1, and there is at least one query of type 2. For each query of type 2 output the answer to it. "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
28795305 |
WARenie |
G |
July 23, 2017, 8 a.m. |
OK |
FPC |
TESTS |
39 |
2557 |
82124800 |
|
2600 |
34101584 |
lyx_cjz |
G |
Jan. 12, 2018, 8:22 a.m. |
OK |
GNU C++ |
TESTS |
39 |
451 |
58163200 |
|
2600 |
30868885 |
Lhtie |
G |
Sept. 30, 2017, 2:17 p.m. |
OK |
GNU C++ |
TESTS |
39 |
483 |
61337600 |
|
2600 |
29844635 |
Scut82 |
G |
Aug. 28, 2017, 11:58 a.m. |
OK |
GNU C++ |
TESTS |
39 |
530 |
83865600 |
|
2600 |
42025486 |
yihhhhhhh |
G |
Aug. 24, 2018, 12:12 p.m. |
OK |
GNU C++ |
TESTS |
39 |
576 |
55910400 |
|
2600 |
34042955 |
Worldwide_D |
G |
Jan. 9, 2018, 7:24 a.m. |
OK |
GNU C++ |
TESTS |
39 |
592 |
57958400 |
|
2600 |
42025423 |
yihhhhhhh |
G |
Aug. 24, 2018, 12:10 p.m. |
OK |
GNU C++ |
TESTS |
39 |
623 |
56217600 |
|
2600 |
29158692 |
mxy |
G |
Aug. 3, 2017, 3:11 p.m. |
OK |
GNU C++ |
TESTS |
39 |
670 |
91238400 |
|
2600 |
28692413 |
huangzhen |
G |
July 19, 2017, 9:43 a.m. |
OK |
GNU C++ |
TESTS |
39 |
841 |
58163200 |
|
2600 |
28920493 |
1234567891 |
G |
July 27, 2017, 4:35 a.m. |
OK |
GNU C++ |
TESTS |
39 |
842 |
57958400 |
|
2600 |
28629852 |
lawyerphx |
G |
July 17, 2017, 6:38 a.m. |
OK |
GNU C++ |
TESTS |
39 |
889 |
63180800 |
|
2600 |
68353474 |
910306264 |
G |
Jan. 7, 2020, 10:58 a.m. |
OK |
GNU C++11 |
TESTS |
39 |
234 |
38604800 |
|
2600 |
44691854 |
yukuai26 |
G |
Oct. 22, 2018, 12:28 p.m. |
OK |
GNU C++11 |
TESTS |
39 |
358 |
60006400 |
|
2600 |
63275357 |
X_o_r |
G |
Oct. 24, 2019, 6:35 a.m. |
OK |
GNU C++11 |
TESTS |
39 |
468 |
56012800 |
|
2600 |
58886576 |
gjghfd |
G |
Aug. 16, 2019, 2:35 a.m. |
OK |
GNU C++11 |
TESTS |
39 |
576 |
51814400 |
|
2600 |
69500353 |
zlczlc |
G |
Jan. 25, 2020, 6:19 a.m. |
OK |
GNU C++11 |
TESTS |
39 |
576 |
76083200 |
|
2600 |
28682744 |
bin_gege |
G |
July 19, 2017, 3:22 a.m. |
OK |
GNU C++11 |
TESTS |
39 |
623 |
142336000 |
|
2600 |
28642689 |
Kmcode |
G |
July 17, 2017, 2:35 p.m. |
OK |
GNU C++11 |
TESTS |
39 |
670 |
57344000 |
|
2600 |
68356133 |
luogu_bot4 |
G |
Jan. 7, 2020, 12:10 p.m. |
OK |
GNU C++11 |
TESTS |
39 |
686 |
36454400 |
|
2600 |
63284154 |
hyacinthLJP |
G |
Oct. 24, 2019, 9:43 a.m. |
OK |
GNU C++11 |
TESTS |
39 |
732 |
56012800 |
|
2600 |
29507473 |
jiachinzhao |
G |
Aug. 16, 2017, 2:14 p.m. |
OK |
GNU C++11 |
TESTS |
39 |
732 |
80179200 |
|
2600 |
40980570 |
ReaLNero1 |
G |
July 30, 2018, 5:35 p.m. |
OK |
GNU C++14 |
TESTS |
39 |
327 |
36454400 |
|
2600 |
30980523 |
zhangzy |
G |
Oct. 4, 2017, 12:54 a.m. |
OK |
GNU C++14 |
TESTS |
39 |
327 |
36454400 |
|
2600 |
28643288 |
radoslav11 |
G |
July 17, 2017, 3:01 p.m. |
OK |
GNU C++14 |
TESTS |
39 |
577 |
83046400 |
|
2600 |
29921510 |
waynetuinfor |
G |
Aug. 30, 2017, 2:38 p.m. |
OK |
GNU C++14 |
TESTS |
39 |
639 |
81305600 |
|
2600 |
28620813 |
MrDindows |
G |
July 16, 2017, 10:17 p.m. |
OK |
GNU C++14 |
TESTS |
39 |
654 |
51507200 |
|
2600 |
28647737 |
radoslav11 |
G |
July 17, 2017, 7:34 p.m. |
OK |
GNU C++14 |
TESTS |
39 |
716 |
83046400 |
|
2600 |
56182683 |
vjudge4 |
G |
June 28, 2019, 1:42 a.m. |
OK |
GNU C++14 |
TESTS |
39 |
935 |
56012800 |
|
2600 |
56157696 |
vjudge1 |
G |
June 27, 2019, 10:59 a.m. |
OK |
GNU C++14 |
TESTS |
39 |
950 |
56012800 |
|
2600 |
56205219 |
vjudge4 |
G |
June 28, 2019, 8:59 a.m. |
OK |
GNU C++14 |
TESTS |
39 |
1014 |
56012800 |
|
2600 |
28865225 |
basasuya |
G |
July 25, 2017, 4:30 a.m. |
OK |
GNU C++14 |
TESTS |
39 |
1028 |
73932800 |
|
2600 |
56485325 |
kostia244 |
G |
July 3, 2019, 6:03 p.m. |
OK |
GNU C++17 |
TESTS |
39 |
654 |
55603200 |
|
2600 |
45989443 |
ZZHzzh0_0 |
G |
Nov. 20, 2018, 8:49 a.m. |
OK |
GNU C++17 |
TESTS |
39 |
655 |
108851200 |
|
2600 |
56182680 |
Sinogi |
G |
June 28, 2019, 1:42 a.m. |
OK |
GNU C++17 |
TESTS |
39 |
998 |
56012800 |
|
2600 |
56160906 |
vjudge1 |
G |
June 27, 2019, 12:17 p.m. |
OK |
GNU C++17 |
TESTS |
39 |
998 |
56012800 |
|
2600 |
45989036 |
ZZHzzh0_0 |
G |
Nov. 20, 2018, 8:36 a.m. |
OK |
GNU C++17 |
TESTS |
39 |
1075 |
56320000 |
|
2600 |
45989056 |
vjudge5 |
G |
Nov. 20, 2018, 8:37 a.m. |
OK |
GNU C++17 |
TESTS |
39 |
1076 |
56320000 |
|
2600 |
61307177 |
yuxizi |
G |
Sept. 26, 2019, 7:47 a.m. |
OK |
GNU C++17 |
TESTS |
39 |
1091 |
60006400 |
|
2600 |
45791570 |
wru |
G |
Nov. 16, 2018, 7:28 a.m. |
OK |
GNU C++17 |
TESTS |
39 |
1091 |
80281600 |
|
2600 |
46003539 |
letmeC |
G |
Nov. 20, 2018, 3:45 p.m. |
OK |
GNU C++17 |
TESTS |
39 |
1107 |
80076800 |
|
2600 |
68075581 |
GioChkhaidze |
G |
Jan. 2, 2020, 12:21 p.m. |
OK |
GNU C++17 |
TESTS |
39 |
1122 |
80281600 |
|
2600 |
28796125 |
uwi |
G |
July 23, 2017, 8:40 a.m. |
OK |
Java 8 |
TESTS |
39 |
733 |
73113600 |
|
2600 |
43736694 |
Ahmad |
G |
Oct. 3, 2018, 4:16 p.m. |
OK |
Java 8 |
TESTS |
39 |
764 |
76083200 |
|
2600 |
28666801 |
Kvark161 |
G |
July 18, 2017, 11:47 a.m. |
OK |
Java 8 |
TESTS |
39 |
2495 |
237568000 |
|
2600 |
29107729 |
Omar_Morsi |
G |
Aug. 1, 2017, 5:20 p.m. |
OK |
Java 8 |
TESTS |
39 |
2652 |
233062400 |
|
2600 |
29149968 |
lunawyll |
G |
Aug. 3, 2017, 8:19 a.m. |
OK |
Java 8 |
TESTS |
39 |
2666 |
268390400 |
|
2600 |
28666697 |
Kvark161 |
G |
July 18, 2017, 11:43 a.m. |
OK |
Java 8 |
TESTS |
39 |
2667 |
255180800 |
|
2600 |
28612978 |
uwi |
G |
July 16, 2017, 4:48 p.m. |
OK |
Java 8 |
TESTS |
39 |
2870 |
253849600 |
|
2600 |
29338336 |
leign |
G |
Aug. 10, 2017, 8:44 p.m. |
OK |
Mono C# |
TESTS |
39 |
2464 |
118784000 |
|
2600 |
29338306 |
leign |
G |
Aug. 10, 2017, 8:41 p.m. |
OK |
Mono C# |
TESTS |
39 |
2464 |
123904000 |
|
2600 |
28821474 |
AnatolyTolstobrov |
G |
July 24, 2017, 10:10 a.m. |
OK |
MS C# |
TESTS |
39 |
1216 |
145817600 |
|
2600 |
29279014 |
bramandia |
G |
Aug. 8, 2017, 6:36 a.m. |
OK |
MS C++ |
TESTS |
39 |
1263 |
62259200 |
|
2600 |
remove filters
Back to search problems