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 New Year holidays are over, but Resha doesn't want to throw away the New Year tree. He invited his best friends Kerim and Gural to help him to redecorate the New Year tree. The New Year tree is an undirected tree with n vertices and root in the vertex 1. You should process the queries of the two types: The first line contains two integers n, xe2 x80 x89m (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n, xe2 x80 x89m xe2 x80 x89 xe2 x89 xa4 xe2 x80 x894 xc2 xb7105) -- the number of vertices in the tree and the number of the queries. The second line contains n integers ci (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89ci xe2 x80 x89 xe2 x89 xa4 xe2 x80 x8960) -- the colour of the i-th vertex. Each of the next n xe2 x80 x89- xe2 x80 x891 lines contains two integers xj, xe2 x80 x89yj (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89xj, xe2 x80 x89yj xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n) -- the vertices of the j-th edge. It is guaranteed that you are given correct undirected tree. The last m lines contains the description of the queries. Each description starts with the integer tk (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89tk xe2 x80 x89 xe2 x89 xa4 xe2 x80 x892) -- the type of the k-th query. For the queries of the first type then follows two integers vk, xe2 x80 x89ck (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89vk xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n, xe2 x80 x891 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89ck xe2 x80 x89 xe2 x89 xa4 xe2 x80 x8960) -- the number of the vertex whose subtree will be recoloured with the colour ck. For the queries of the second type then follows integer vk (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89vk xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n) -- the number of the vertex for which subtree you should find the number of different colours. For each query of the second type print the integer a -- the number of different colours in the subtree of the vertex given in the query. Each of the numbers should be printed on a separate line in order of query appearing in the input."... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
15486938 |
rais.fathin38 |
E |
Jan. 21, 2016, 9:54 p.m. |
OK |
D |
TESTS |
72 |
1809 |
77004800 |
|
2100 |
15751811 |
Astreb |
E |
Feb. 2, 2016, 2:12 p.m. |
OK |
FPC |
TESTS |
72 |
1216 |
59494400 |
|
2100 |
35976836 |
Slonik |
E |
March 5, 2018, 8:45 p.m. |
OK |
FPC |
TESTS |
72 |
1325 |
59801600 |
|
2100 |
15501295 |
igdor99 |
E |
Jan. 22, 2016, 4:14 p.m. |
OK |
FPC |
TESTS |
72 |
1356 |
67072000 |
|
2100 |
35976724 |
Slonik |
E |
March 5, 2018, 8:37 p.m. |
OK |
FPC |
TESTS |
72 |
1403 |
59801600 |
|
2100 |
16768237 |
dathvan |
E |
March 17, 2016, 4:58 p.m. |
OK |
FPC |
TESTS |
72 |
1684 |
78643200 |
|
2100 |
49624223 |
AHTOH._. |
E |
Feb. 8, 2019, 11:02 a.m. |
OK |
FPC |
TESTS |
72 |
1716 |
59699200 |
|
2100 |
15680898 |
Castrop-Rauxel |
E |
Jan. 30, 2016, 3:24 p.m. |
OK |
FPC |
TESTS |
72 |
1840 |
87654400 |
|
2100 |
15481146 |
sgtlaugh |
E |
Jan. 21, 2016, 4:39 p.m. |
OK |
GNU C |
TESTS |
72 |
748 |
61030400 |
|
2100 |
41530216 |
luogu_bot4 |
E |
Aug. 12, 2018, 2:05 p.m. |
OK |
GNU C++ |
TESTS |
72 |
373 |
38604800 |
|
2100 |
41323549 |
luogu_bot2 |
E |
Aug. 8, 2018, 3:11 a.m. |
OK |
GNU C++ |
TESTS |
72 |
373 |
38604800 |
|
2100 |
40985293 |
ReaLNero1 |
E |
July 30, 2018, 7:52 p.m. |
OK |
GNU C++ |
TESTS |
72 |
374 |
54886400 |
|
2100 |
35777444 |
luogu_bot4 |
E |
Feb. 28, 2018, 7:45 a.m. |
OK |
GNU C++ |
TESTS |
72 |
374 |
56934400 |
|
2100 |
35777455 |
yybyyb |
E |
Feb. 28, 2018, 7:45 a.m. |
OK |
GNU C++ |
TESTS |
72 |
389 |
56934400 |
|
2100 |
41682559 |
void_f |
E |
Aug. 17, 2018, 11:58 a.m. |
OK |
GNU C++ |
TESTS |
72 |
405 |
38604800 |
|
2100 |
42221651 |
vjudge3 |
E |
Aug. 28, 2018, 9:13 p.m. |
OK |
GNU C++ |
TESTS |
72 |
405 |
46284800 |
|
2100 |
36895081 |
luogu_bot1 |
E |
April 3, 2018, 7:06 a.m. |
OK |
GNU C++ |
TESTS |
72 |
405 |
56217600 |
|
2100 |
31597187 |
qaz_kyle |
E |
Oct. 22, 2017, 8:16 a.m. |
OK |
GNU C++ |
TESTS |
72 |
421 |
42188800 |
|
2100 |
38633501 |
vjudge5 |
E |
May 26, 2018, 12:33 p.m. |
OK |
GNU C++ |
TESTS |
72 |
421 |
69324800 |
|
2100 |
56733280 |
sansen |
E |
July 9, 2019, 3:11 a.m. |
OK |
GNU C11 |
TESTS |
72 |
452 |
57753600 |
|
2100 |
56731858 |
sansen |
E |
July 9, 2019, 2:03 a.m. |
OK |
GNU C11 |
TESTS |
72 |
452 |
57753600 |
|
2100 |
56731525 |
sansen |
E |
July 9, 2019, 1:48 a.m. |
OK |
GNU C11 |
TESTS |
72 |
686 |
66662400 |
|
2100 |
58180631 |
rainboy |
E |
Aug. 2, 2019, 3:02 p.m. |
OK |
GNU C11 |
TESTS |
72 |
1497 |
36147200 |
|
2100 |
48316058 |
changle_cyx |
E |
Jan. 13, 2019, 6:37 a.m. |
OK |
GNU C++11 |
TESTS |
72 |
280 |
38604800 |
|
2100 |
49818244 |
Taday |
E |
Feb. 12, 2019, 7:15 a.m. |
OK |
GNU C++11 |
TESTS |
72 |
295 |
38604800 |
|
2100 |
65730522 |
910306264 |
E |
Nov. 26, 2019, 4:43 a.m. |
OK |
GNU C++11 |
TESTS |
72 |
295 |
48742400 |
|
2100 |
61331597 |
luogu_bot1 |
E |
Sept. 26, 2019, 3:10 p.m. |
OK |
GNU C++11 |
TESTS |
72 |
296 |
45056000 |
|
2100 |
53897211 |
lohannes |
E |
May 9, 2019, 6:50 a.m. |
OK |
GNU C++11 |
TESTS |
72 |
311 |
52838400 |
|
2100 |
61331764 |
luogu_bot3 |
E |
Sept. 26, 2019, 3:12 p.m. |
OK |
GNU C++11 |
TESTS |
72 |
327 |
45056000 |
|
2100 |
55114605 |
ctz45562 |
E |
June 5, 2019, 8:04 a.m. |
OK |
GNU C++11 |
TESTS |
72 |
327 |
46489600 |
|
2100 |
55114653 |
luogu_bot1 |
E |
June 5, 2019, 8:06 a.m. |
OK |
GNU C++11 |
TESTS |
72 |
327 |
46489600 |
|
2100 |
53012780 |
luogu_bot5 |
E |
April 19, 2019, 12:51 p.m. |
OK |
GNU C++11 |
TESTS |
72 |
327 |
48025600 |
|
2100 |
53012692 |
luogu_bot5 |
E |
April 19, 2019, 12:49 p.m. |
OK |
GNU C++11 |
TESTS |
72 |
327 |
48025600 |
|
2100 |
30257331 |
NiroBC |
E |
Sept. 11, 2017, 1:05 a.m. |
OK |
GNU C++14 |
TESTS |
72 |
312 |
28364800 |
|
2100 |
31192976 |
vjudge2 |
E |
Oct. 10, 2017, 2:49 p.m. |
OK |
GNU C++14 |
TESTS |
72 |
545 |
52940800 |
|
2100 |
35604431 |
vjudge4 |
E |
Feb. 23, 2018, 5:11 p.m. |
OK |
GNU C++14 |
TESTS |
72 |
701 |
61747200 |
|
2100 |
33249112 |
igand |
E |
Dec. 14, 2017, 7:13 p.m. |
OK |
GNU C++14 |
TESTS |
72 |
717 |
53452800 |
|
2100 |
31786893 |
wjw1340 |
E |
Oct. 27, 2017, 7:42 a.m. |
OK |
GNU C++14 |
TESTS |
72 |
717 |
67276800 |
|
2100 |
57790523 |
geezers |
E |
July 26, 2019, 9:16 a.m. |
OK |
GNU C++14 |
TESTS |
72 |
717 |
189132800 |
|
2100 |
44828241 |
wzz-huchi |
E |
Oct. 25, 2018, 7:17 a.m. |
OK |
GNU C++14 |
TESTS |
72 |
732 |
62873600 |
|
2100 |
35614280 |
vjudge3 |
E |
Feb. 24, 2018, 3:38 a.m. |
OK |
GNU C++14 |
TESTS |
72 |
732 |
77312000 |
|
2100 |
61322173 |
Chr1stopher |
E |
Sept. 26, 2019, 12:53 p.m. |
OK |
GNU C++14 |
TESTS |
72 |
732 |
96153600 |
|
2100 |
38103304 |
wleung_bvg |
E |
May 11, 2018, 1:07 a.m. |
OK |
GNU C++14 |
TESTS |
72 |
733 |
49971200 |
|
2100 |
49047712 |
libra8z |
E |
Jan. 27, 2019, 9:37 a.m. |
OK |
GNU C++17 |
TESTS |
72 |
295 |
40448000 |
|
2100 |
49047750 |
vjudge3 |
E |
Jan. 27, 2019, 9:38 a.m. |
OK |
GNU C++17 |
TESTS |
72 |
327 |
40448000 |
|
2100 |
58986324 |
vjudge3 |
E |
Aug. 18, 2019, 7:14 a.m. |
OK |
GNU C++17 |
TESTS |
72 |
389 |
65945600 |
|
2100 |
58986298 |
vjudge1 |
E |
Aug. 18, 2019, 7:14 a.m. |
OK |
GNU C++17 |
TESTS |
72 |
390 |
65945600 |
|
2100 |
45197207 |
xymtxdy |
E |
Nov. 2, 2018, 7:51 a.m. |
OK |
GNU C++17 |
TESTS |
72 |
483 |
205516800 |
|
2100 |
48772701 |
aakk |
E |
Jan. 23, 2019, 1:41 a.m. |
OK |
GNU C++17 |
TESTS |
72 |
702 |
46694400 |
|
2100 |
56732133 |
vjudge1 |
E |
July 9, 2019, 2:17 a.m. |
OK |
GNU C++17 |
TESTS |
72 |
717 |
47923200 |
|
2100 |
64161725 |
Mai-sanBestWaifu |
E |
Nov. 3, 2019, 2:45 p.m. |
OK |
GNU C++17 |
TESTS |
72 |
717 |
47923200 |
|
2100 |
58343100 |
yehuan |
E |
Aug. 5, 2019, 1:55 p.m. |
OK |
GNU C++17 |
TESTS |
72 |
717 |
100966400 |
|
2100 |
44352772 |
vjudge1 |
E |
Oct. 15, 2018, 11 a.m. |
OK |
GNU C++17 |
TESTS |
72 |
733 |
78745600 |
|
2100 |
20153503 |
pavel.rosputko |
E |
Aug. 25, 2016, 12:18 p.m. |
OK |
Haskell |
TESTS |
72 |
1746 |
149299200 |
|
2100 |
20154218 |
pavel.rosputko |
E |
Aug. 25, 2016, 12:50 p.m. |
OK |
Haskell |
TESTS |
72 |
1918 |
193126400 |
|
2100 |
20154032 |
pavel.rosputko |
E |
Aug. 25, 2016, 12:42 p.m. |
OK |
Haskell |
TESTS |
72 |
1965 |
193126400 |
|
2100 |
68101629 |
GiantTornado |
E |
Jan. 3, 2020, 3:40 a.m. |
OK |
Java 11 |
TESTS |
72 |
1450 |
107315200 |
|
2100 |
68101422 |
GiantTornado |
E |
Jan. 3, 2020, 3:26 a.m. |
OK |
Java 11 |
TESTS |
72 |
2932 |
210022400 |
|
2100 |
15607456 |
mbrc |
E |
Jan. 27, 2016, 8 a.m. |
OK |
Java 7 |
TESTS |
72 |
1419 |
224563200 |
|
2100 |
15478664 |
anandpatel9998 |
E |
Jan. 21, 2016, 4:06 p.m. |
OK |
Java 7 |
TESTS |
72 |
1513 |
203673600 |
|
2100 |
15482965 |
akdent |
E |
Jan. 21, 2016, 5:08 p.m. |
OK |
Java 7 |
TESTS |
72 |
1544 |
189030400 |
|
2100 |
15502762 |
Guliash |
E |
Jan. 22, 2016, 6:03 p.m. |
OK |
Java 7 |
TESTS |
72 |
1559 |
186777600 |
|
2100 |
15959121 |
killgame |
E |
Feb. 11, 2016, 3:49 p.m. |
OK |
Java 7 |
TESTS |
72 |
1980 |
243404800 |
|
2100 |
15957395 |
killgame |
E |
Feb. 11, 2016, 2:08 p.m. |
OK |
Java 7 |
TESTS |
72 |
2074 |
243404800 |
|
2100 |
15600996 |
paletov |
E |
Jan. 26, 2016, 8:10 p.m. |
OK |
Java 7 |
TESTS |
72 |
2152 |
243404800 |
|
2100 |
15639143 |
alibaba |
E |
Jan. 29, 2016, 4:18 a.m. |
OK |
Java 7 |
TESTS |
72 |
2402 |
158617600 |
|
2100 |
15485328 |
uwi |
E |
Jan. 21, 2016, 7:12 p.m. |
OK |
Java 8 |
TESTS |
72 |
795 |
18022400 |
|
2100 |
65447417 |
jenish9599 |
E |
Nov. 20, 2019, 4:32 p.m. |
OK |
Java 8 |
TESTS |
72 |
842 |
103424000 |
|
2100 |
15483467 |
fetetriste |
E |
Jan. 21, 2016, 5:26 p.m. |
OK |
Java 8 |
TESTS |
72 |
1107 |
53657600 |
|
2100 |
51361305 |
trungdovan87 |
E |
March 16, 2019, 7:26 a.m. |
OK |
Java 8 |
TESTS |
72 |
1107 |
96153600 |
|
2100 |
15499027 |
dhrumil140396 |
E |
Jan. 22, 2016, 1:38 p.m. |
OK |
Java 8 |
TESTS |
72 |
1107 |
151449600 |
|
2100 |
31704487 |
parth_15 |
E |
Oct. 25, 2017, 9:49 a.m. |
OK |
Java 8 |
TESTS |
72 |
1107 |
211763200 |
|
2100 |
27825384 |
Maulik_Patel |
E |
June 16, 2017, 12:54 p.m. |
OK |
Java 8 |
TESTS |
72 |
1122 |
173465600 |
|
2100 |
23381591 |
U_Square |
E |
Dec. 28, 2016, 4:06 p.m. |
OK |
Java 8 |
TESTS |
72 |
1123 |
185036800 |
|
2100 |
31704509 |
parth_15 |
E |
Oct. 25, 2017, 9:51 a.m. |
OK |
Java 8 |
TESTS |
72 |
1169 |
211865600 |
|
2100 |
41974121 |
IDzekh |
E |
Aug. 22, 2018, 5:17 p.m. |
OK |
Java 8 |
TESTS |
72 |
1232 |
106598400 |
|
2100 |
38102709 |
wleung_bvg |
E |
May 10, 2018, 11:30 p.m. |
OK |
Mono C# |
TESTS |
72 |
1746 |
212172800 |
|
2100 |
15482694 |
og.kostya |
E |
Jan. 21, 2016, 4:59 p.m. |
OK |
MS C# |
TESTS |
72 |
794 |
92262400 |
|
2100 |
17715305 |
azukun |
E |
May 5, 2016, 7:24 a.m. |
OK |
MS C# |
TESTS |
72 |
872 |
101068800 |
|
2100 |
17715152 |
azukun |
E |
May 5, 2016, 6:56 a.m. |
OK |
MS C# |
TESTS |
72 |
967 |
107622400 |
|
2100 |
17715115 |
azukun |
E |
May 5, 2016, 6:49 a.m. |
OK |
MS C# |
TESTS |
72 |
997 |
107929600 |
|
2100 |
17715204 |
azukun |
E |
May 5, 2016, 7:04 a.m. |
OK |
MS C# |
TESTS |
72 |
1060 |
111513600 |
|
2100 |
17715079 |
azukun |
E |
May 5, 2016, 6:45 a.m. |
OK |
MS C# |
TESTS |
72 |
1075 |
107724800 |
|
2100 |
17715131 |
azukun |
E |
May 5, 2016, 6:53 a.m. |
OK |
MS C# |
TESTS |
72 |
1185 |
107724800 |
|
2100 |
17715161 |
azukun |
E |
May 5, 2016, 6:58 a.m. |
OK |
MS C# |
TESTS |
72 |
1185 |
107929600 |
|
2100 |
15495740 |
toraoh |
E |
Jan. 22, 2016, 9:30 a.m. |
OK |
MS C# |
TESTS |
72 |
1497 |
92569600 |
|
2100 |
15495657 |
toraoh |
E |
Jan. 22, 2016, 9:25 a.m. |
OK |
MS C# |
TESTS |
72 |
1590 |
92467200 |
|
2100 |
15483137 |
Adhambek |
E |
Jan. 21, 2016, 5:13 p.m. |
OK |
MS C++ |
TESTS |
72 |
545 |
83353600 |
|
2100 |
64525469 |
vjudge4 |
E |
Nov. 8, 2019, 1:40 p.m. |
OK |
MS C++ |
TESTS |
72 |
561 |
43212800 |
|
2100 |
58262625 |
vjudge2 |
E |
Aug. 4, 2019, 1 p.m. |
OK |
MS C++ |
TESTS |
72 |
607 |
81305600 |
|
2100 |
59379820 |
vjudge1 |
E |
Aug. 24, 2019, 2:05 a.m. |
OK |
MS C++ |
TESTS |
72 |
624 |
89702400 |
|
2100 |
58263006 |
vjudge1 |
E |
Aug. 4, 2019, 1:12 p.m. |
OK |
MS C++ |
TESTS |
72 |
655 |
81305600 |
|
2100 |
16013410 |
sister_what_hate_most |
E |
Feb. 14, 2016, 6:14 a.m. |
OK |
MS C++ |
TESTS |
72 |
670 |
51302400 |
|
2100 |
58314111 |
vjudge3 |
E |
Aug. 5, 2019, 1:53 a.m. |
OK |
MS C++ |
TESTS |
72 |
670 |
77312000 |
|
2100 |
53037097 |
vjudge1 |
E |
April 20, 2019, 7:53 a.m. |
OK |
MS C++ |
TESTS |
72 |
670 |
112230400 |
|
2100 |
53044457 |
vjudge2 |
E |
April 20, 2019, 11:30 a.m. |
OK |
MS C++ |
TESTS |
72 |
670 |
112230400 |
|
2100 |
59379812 |
vjudge4 |
E |
Aug. 24, 2019, 2:04 a.m. |
OK |
MS C++ |
TESTS |
72 |
685 |
64102400 |
|
2100 |
62685940 |
vjudge2 |
E |
Oct. 16, 2019, 2:04 p.m. |
OK |
MS C++ 2017 |
TESTS |
72 |
779 |
72089600 |
|
2100 |
54561773 |
ChaLemon |
E |
May 24, 2019, 2:17 p.m. |
OK |
MS C++ 2017 |
TESTS |
72 |
935 |
70553600 |
|
2100 |
69939734 |
TrickmanOff |
E |
Feb. 1, 2020, 5:42 a.m. |
OK |
MS C++ 2017 |
TESTS |
72 |
2027 |
65945600 |
|
2100 |
remove filters
Back to search problems