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 with n nodes, numerated from 0 to n-1 . For each k between 0 and n , inclusive, you have to count the number of unordered pairs (u,v) , u neq v , such that the MEX of all the node labels in the shortest path from u to v (including end points) is k . The MEX of a sequence of integers is the smallest non-negative integer that does not belong to the sequence. The first line contains a single integer t ( 1 <= t <= 10^4 ) -- the number of test cases. The first line of each test case contains a single integer n ( 2 <= n <= 2 cdot 10^{5} ). The next n-1 lines of each test case describe the tree that has to be constructed. These lines contain two integers u and v ( 0 <= u,v <= n-1 ) denoting an edge between u and v ( u neq v ). It is guaranteed that the given edges form a tree. It is also guaranteed that the sum of n for all test cases does not exceed 2 cdot 10^{5} . For each test case, print n+1 integers: the number of paths in the tree, such that the MEX of all the node labels in that path is k for each k from 0 to n . '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
116859380 |
rainboy |
D |
May 20, 2021, 8:38 p.m. |
OK |
GNU C11 |
TESTS |
26 |
795 |
14233600 |
|
2400 |
116862212 |
Ecrade_ |
D |
May 20, 2021, 10:01 p.m. |
OK |
GNU C++11 |
TESTS |
26 |
78 |
22630400 |
|
2400 |
116866377 |
Suiseiseki |
D |
May 21, 2021, 1:06 a.m. |
OK |
GNU C++11 |
TESTS |
26 |
93 |
11161600 |
|
2400 |
116866198 |
CSHwang |
D |
May 21, 2021, 12:59 a.m. |
OK |
GNU C++11 |
TESTS |
26 |
93 |
16179200 |
|
2400 |
116872802 |
LegendaryYYQ |
D |
May 21, 2021, 3:33 a.m. |
OK |
GNU C++11 |
TESTS |
26 |
93 |
54272000 |
|
2400 |
116841413 |
namelessgugugu |
D |
May 20, 2021, 4:33 p.m. |
OK |
GNU C++11 |
TESTS |
25 |
109 |
14950400 |
|
2400 |
116875681 |
ASTROBOYZZ |
D |
May 21, 2021, 4:19 a.m. |
OK |
GNU C++11 |
TESTS |
26 |
124 |
21913600 |
|
2400 |
116851809 |
KurisuMakise |
D |
May 20, 2021, 6:31 p.m. |
OK |
GNU C++11 |
TESTS |
26 |
124 |
26726400 |
|
2400 |
116845631 |
Acranker |
D |
May 20, 2021, 5:36 p.m. |
OK |
GNU C++11 |
TESTS |
25 |
124 |
29593600 |
|
2400 |
116876333 |
DataStructures |
D |
May 21, 2021, 4:29 a.m. |
OK |
GNU C++11 |
TESTS |
26 |
140 |
20992000 |
|
2400 |
116874245 |
KurisuMakise |
D |
May 21, 2021, 3:56 a.m. |
OK |
GNU C++11 |
TESTS |
26 |
140 |
26726400 |
|
2400 |
116877555 |
ajj |
D |
May 21, 2021, 4:46 a.m. |
OK |
GNU C++14 |
TESTS |
26 |
155 |
16793600 |
|
2400 |
116872706 |
18380120126 |
D |
May 21, 2021, 3:31 a.m. |
OK |
GNU C++14 |
TESTS |
26 |
171 |
15155200 |
|
2400 |
116877403 |
ajj |
D |
May 21, 2021, 4:44 a.m. |
OK |
GNU C++14 |
TESTS |
26 |
186 |
16793600 |
|
2400 |
116854868 |
Hermit__OvO |
D |
May 20, 2021, 7:14 p.m. |
OK |
GNU C++14 |
TESTS |
26 |
187 |
18944000 |
|
2400 |
116859154 |
shashwat259 |
D |
May 20, 2021, 8:33 p.m. |
OK |
GNU C++14 |
TESTS |
26 |
202 |
23756800 |
|
2400 |
116876734 |
Hung912 |
D |
May 21, 2021, 4:35 a.m. |
OK |
GNU C++14 |
TESTS |
26 |
202 |
32768000 |
|
2400 |
116871672 |
_Ruri_ |
D |
May 21, 2021, 3:14 a.m. |
OK |
GNU C++14 |
TESTS |
26 |
202 |
33075200 |
|
2400 |
116866436 |
ntdung |
D |
May 21, 2021, 1:08 a.m. |
OK |
GNU C++14 |
TESTS |
26 |
202 |
38400000 |
|
2400 |
116876341 |
LushCat |
D |
May 21, 2021, 4:29 a.m. |
OK |
GNU C++14 |
TESTS |
26 |
202 |
45465600 |
|
2400 |
116879805 |
Never_Do_it |
D |
May 21, 2021, 5:18 a.m. |
OK |
GNU C++14 |
TESTS |
26 |
217 |
17510400 |
|
2400 |
116868168 |
Terryjoy |
D |
May 21, 2021, 2:02 a.m. |
OK |
GNU C++17 |
TESTS |
26 |
139 |
9625600 |
|
2400 |
116866327 |
ZHAKWF |
D |
May 21, 2021, 1:04 a.m. |
OK |
GNU C++17 |
TESTS |
26 |
140 |
16793600 |
|
2400 |
116852425 |
idk321 |
D |
May 20, 2021, 6:38 p.m. |
OK |
GNU C++17 |
TESTS |
26 |
155 |
15155200 |
|
2400 |
116847501 |
abhinavvv306 |
D |
May 20, 2021, 5:49 p.m. |
OK |
GNU C++17 |
TESTS |
25 |
155 |
19148800 |
|
2400 |
116880599 |
bobh |
D |
May 21, 2021, 5:28 a.m. |
OK |
GNU C++17 |
TESTS |
26 |
156 |
15155200 |
|
2400 |
116864164 |
ShJ |
D |
May 20, 2021, 11:29 p.m. |
OK |
GNU C++17 |
TESTS |
26 |
156 |
15155200 |
|
2400 |
116865924 |
gzu_eternity |
D |
May 21, 2021, 12:48 a.m. |
OK |
GNU C++17 |
TESTS |
26 |
170 |
19353600 |
|
2400 |
116866229 |
Hex1234567 |
D |
May 21, 2021, 1 a.m. |
OK |
GNU C++17 |
TESTS |
26 |
171 |
16179200 |
|
2400 |
116865694 |
HexQwQ |
D |
May 21, 2021, 12:38 a.m. |
OK |
GNU C++17 |
TESTS |
26 |
171 |
16179200 |
|
2400 |
116858527 |
codicon |
D |
May 20, 2021, 8:20 p.m. |
OK |
GNU C++17 |
TESTS |
26 |
171 |
16793600 |
|
2400 |
116850633 |
iamnifer |
D |
May 20, 2021, 6:18 p.m. |
OK |
GNU C++17 (64) |
TESTS |
26 |
108 |
26624000 |
|
2400 |
116859388 |
rainboy |
D |
May 20, 2021, 8:39 p.m. |
OK |
GNU C++17 (64) |
TESTS |
26 |
124 |
21299200 |
|
2400 |
116850425 |
iamnifer |
D |
May 20, 2021, 6:16 p.m. |
OK |
GNU C++17 (64) |
TESTS |
26 |
140 |
22425600 |
|
2400 |
116852079 |
magnified |
D |
May 20, 2021, 6:34 p.m. |
OK |
GNU C++17 (64) |
TESTS |
26 |
155 |
23859200 |
|
2400 |
116863029 |
WeakestTopology |
D |
May 20, 2021, 10:36 p.m. |
OK |
GNU C++17 (64) |
TESTS |
26 |
155 |
24678400 |
|
2400 |
116864549 |
Keep_Coding |
D |
May 20, 2021, 11:49 p.m. |
OK |
GNU C++17 (64) |
TESTS |
26 |
155 |
25190400 |
|
2400 |
116857738 |
izlyforever |
D |
May 20, 2021, 8:04 p.m. |
OK |
GNU C++17 (64) |
TESTS |
26 |
155 |
27033600 |
|
2400 |
116866658 |
zerver52 |
D |
May 21, 2021, 1:15 a.m. |
OK |
GNU C++17 (64) |
TESTS |
26 |
155 |
36659200 |
|
2400 |
116860109 |
chinese |
D |
May 20, 2021, 8:57 p.m. |
OK |
GNU C++17 (64) |
TESTS |
26 |
155 |
37888000 |
|
2400 |
116845531 |
its_never_too_late |
D |
May 20, 2021, 5:36 p.m. |
OK |
GNU C++17 (64) |
TESTS |
25 |
156 |
25190400 |
|
2400 |
116856217 |
Discombobulated |
D |
May 20, 2021, 7:36 p.m. |
OK |
Java 11 |
TESTS |
26 |
420 |
41574400 |
|
2400 |
116860776 |
Apfeloxid |
D |
May 20, 2021, 9:14 p.m. |
OK |
Java 11 |
TESTS |
26 |
670 |
41676800 |
|
2400 |
116849269 |
Dukkha |
D |
May 20, 2021, 6:04 p.m. |
OK |
Java 11 |
TESTS |
26 |
748 |
13312000 |
|
2400 |
116868843 |
pulkit1411 |
D |
May 21, 2021, 2:17 a.m. |
OK |
Java 8 |
TESTS |
26 |
1200 |
85196800 |
|
2400 |
116847164 |
pichulia |
D |
May 20, 2021, 5:46 p.m. |
OK |
MS C++ 2017 |
TESTS |
25 |
249 |
34611200 |
|
2400 |
116882041 |
mban259 |
D |
May 21, 2021, 5:46 a.m. |
OK |
.NET Core C# |
TESTS |
26 |
670 |
62054400 |
|
2400 |
116855404 |
weak-chicken |
D |
May 20, 2021, 7:23 p.m. |
OK |
PyPy 3 |
TESTS |
26 |
467 |
53043200 |
|
2400 |
116848085 |
at_f |
D |
May 20, 2021, 5:53 p.m. |
OK |
PyPy 3 |
TESTS |
25 |
904 |
110592000 |
|
2400 |
116845574 |
sansen |
D |
May 20, 2021, 5:36 p.m. |
OK |
Rust |
TESTS |
25 |
124 |
19865600 |
|
2400 |
116847899 |
ngtkana |
D |
May 20, 2021, 5:51 p.m. |
OK |
Rust |
TESTS |
25 |
311 |
35430400 |
|
2400 |
remove filters
Back to search problems