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'Evlampiy was gifted a rooted tree. The vertices of the tree are numbered from 1 to n . Each of its vertices also has an integer a_i written on it. For each vertex i , Evlampiy calculated c_i -- the number of vertices j in the subtree of vertex i , such that a_j < a_i . After the new year, Evlampiy could not remember what his gift was! He remembers the tree and the values of c_i , but he completely forgot which integers a_i were written on the vertices. Help him to restore initial integers! The first line contains an integer n (1 <= q n <= q 2000) -- the number of vertices in the tree. The next n lines contain descriptions of vertices: the i -th line contains two integers p_i and c_i ( 0 <= q p_i <= q n ; 0 <= q c_i <= q n-1 ), where p_i is the parent of vertex i or 0 if vertex i is root, and c_i is the number of vertices j in the subtree of vertex i , such that a_j < a_i . It is guaranteed that the values of p_i describe a rooted tree with n vertices. If a solution exists, in the first line print "YES", and in the second line output n integers a_i (1 <= q a_i <= q {10}^{9}) . If there are several solutions, output any of them. One can prove that if there is a solution, then there is also a solution in which all a_i are between 1 and 10^9 . If there are no solutions, print "NO". '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
68265643 |
avm |
B |
Jan. 5, 2020, 3:13 p.m. |
OK |
D |
TESTS |
71 |
46 |
25292800 |
|
2000 |
68263665 |
iica |
B |
Jan. 5, 2020, 3:05 p.m. |
OK |
D |
TESTS |
71 |
109 |
36147200 |
|
2000 |
68272720 |
hos.lyric |
B |
Jan. 5, 2020, 3:43 p.m. |
OK |
D |
TESTS |
71 |
530 |
11878400 |
|
2000 |
68260381 |
physics0523 |
B |
Jan. 5, 2020, 2:52 p.m. |
OK |
GNU C11 |
TESTS |
71 |
61 |
46284800 |
|
2000 |
68345502 |
yussgrw |
B |
Jan. 7, 2020, 6:58 a.m. |
OK |
GNU C++11 |
TESTS |
71 |
31 |
0 |
|
2000 |
68363086 |
cfabcdhhhh |
B |
Jan. 7, 2020, 2:52 p.m. |
OK |
GNU C++11 |
TESTS |
71 |
31 |
0 |
|
2000 |
69445017 |
urchin-c |
B |
Jan. 24, 2020, 2:01 a.m. |
OK |
GNU C++11 |
TESTS |
71 |
31 |
102400 |
|
2000 |
69243079 |
Pigbrain |
B |
Jan. 21, 2020, 12:05 p.m. |
OK |
GNU C++11 |
TESTS |
71 |
31 |
102400 |
|
2000 |
68777756 |
Big_black_jujube |
B |
Jan. 14, 2020, 1:59 p.m. |
OK |
GNU C++11 |
TESTS |
71 |
31 |
102400 |
|
2000 |
68773127 |
Glu_TtoNy |
B |
Jan. 14, 2020, 12:34 p.m. |
OK |
GNU C++11 |
TESTS |
71 |
31 |
102400 |
|
2000 |
68773055 |
vjudge1 |
B |
Jan. 14, 2020, 12:33 p.m. |
OK |
GNU C++11 |
TESTS |
71 |
31 |
102400 |
|
2000 |
68760015 |
luogu_bot5 |
B |
Jan. 14, 2020, 8:28 a.m. |
OK |
GNU C++11 |
TESTS |
71 |
31 |
102400 |
|
2000 |
68759875 |
SpaceX3 |
B |
Jan. 14, 2020, 8:26 a.m. |
OK |
GNU C++11 |
TESTS |
71 |
31 |
102400 |
|
2000 |
69520101 |
yuzhechuan |
B |
Jan. 25, 2020, 1:11 p.m. |
OK |
GNU C++11 |
TESTS |
71 |
31 |
102400 |
|
2000 |
68741055 |
gtostes |
B |
Jan. 14, 2020, 1:06 a.m. |
OK |
GNU C++14 |
TESTS |
71 |
30 |
512000 |
|
2000 |
68327422 |
HARD025 |
B |
Jan. 6, 2020, 5:24 p.m. |
OK |
GNU C++14 |
TESTS |
71 |
30 |
11878400 |
|
2000 |
68261488 |
28164811QuangLM |
B |
Jan. 5, 2020, 2:56 p.m. |
OK |
GNU C++14 |
TESTS |
71 |
30 |
19763200 |
|
2000 |
68910151 |
shiliangzhi |
B |
Jan. 16, 2020, 7:30 a.m. |
OK |
GNU C++14 |
TESTS |
71 |
31 |
102400 |
|
2000 |
68255225 |
wucstdio |
B |
Jan. 5, 2020, 2:33 p.m. |
OK |
GNU C++14 |
TESTS |
71 |
31 |
102400 |
|
2000 |
68254586 |
_no0B |
B |
Jan. 5, 2020, 2:31 p.m. |
OK |
GNU C++14 |
TESTS |
71 |
31 |
102400 |
|
2000 |
68681694 |
longNH.IT17 |
B |
Jan. 12, 2020, 10:57 p.m. |
OK |
GNU C++14 |
TESTS |
71 |
31 |
307200 |
|
2000 |
69184874 |
HansLjy |
B |
Jan. 20, 2020, 11:36 a.m. |
OK |
GNU C++14 |
TESTS |
71 |
31 |
307200 |
|
2000 |
69007106 |
melancholic_fat_otaku |
B |
Jan. 18, 2020, 12:40 a.m. |
OK |
GNU C++14 |
TESTS |
71 |
31 |
307200 |
|
2000 |
68721637 |
coding_panda |
B |
Jan. 13, 2020, 4:29 p.m. |
OK |
GNU C++14 |
TESTS |
71 |
31 |
307200 |
|
2000 |
68288887 |
Mohammad_Yasser |
B |
Jan. 5, 2020, 7:52 p.m. |
OK |
GNU C++17 |
TESTS |
71 |
30 |
307200 |
|
2000 |
68427774 |
Primusa |
B |
Jan. 9, 2020, 5 a.m. |
OK |
GNU C++17 |
TESTS |
71 |
30 |
307200 |
|
2000 |
68324751 |
xyqkoala |
B |
Jan. 6, 2020, 4:25 p.m. |
OK |
GNU C++17 |
TESTS |
71 |
30 |
409600 |
|
2000 |
68298835 |
lqs2015 |
B |
Jan. 6, 2020, 5:10 a.m. |
OK |
GNU C++17 |
TESTS |
71 |
30 |
409600 |
|
2000 |
68338545 |
okwedook |
B |
Jan. 7, 2020, 1:01 a.m. |
OK |
GNU C++17 |
TESTS |
71 |
30 |
409600 |
|
2000 |
68253635 |
Minnakhmetov |
B |
Jan. 5, 2020, 2:28 p.m. |
OK |
GNU C++17 |
TESTS |
71 |
30 |
512000 |
|
2000 |
68438274 |
Medusa |
B |
Jan. 9, 2020, 9:52 a.m. |
OK |
GNU C++17 |
TESTS |
71 |
30 |
614400 |
|
2000 |
68254227 |
catupper |
B |
Jan. 5, 2020, 2:30 p.m. |
OK |
GNU C++17 |
TESTS |
71 |
30 |
4198400 |
|
2000 |
68255405 |
cxaphoenix |
B |
Jan. 5, 2020, 2:33 p.m. |
OK |
GNU C++17 |
TESTS |
71 |
30 |
11878400 |
|
2000 |
69093819 |
vjudge4 |
B |
Jan. 19, 2020, 11:13 a.m. |
OK |
GNU C++17 |
TESTS |
71 |
31 |
102400 |
|
2000 |
68665597 |
JHSN |
B |
Jan. 12, 2020, 3:01 p.m. |
OK |
Go |
TESTS |
71 |
109 |
102400 |
|
2000 |
68256270 |
ilyakor |
B |
Jan. 5, 2020, 2:36 p.m. |
OK |
Java 11 |
TESTS |
71 |
218 |
0 |
|
2000 |
68496940 |
arran |
B |
Jan. 10, 2020, 1:52 p.m. |
OK |
Java 11 |
TESTS |
71 |
249 |
0 |
|
2000 |
68261123 |
mikit |
B |
Jan. 5, 2020, 2:55 p.m. |
OK |
Java 11 |
TESTS |
71 |
249 |
0 |
|
2000 |
68286342 |
ZeyadKhattab |
B |
Jan. 5, 2020, 6:39 p.m. |
OK |
Java 11 |
TESTS |
71 |
545 |
0 |
|
2000 |
68285852 |
ZeyadKhattab |
B |
Jan. 5, 2020, 6:27 p.m. |
OK |
Java 11 |
TESTS |
71 |
576 |
0 |
|
2000 |
68262619 |
ZeyadKhattab |
B |
Jan. 5, 2020, 3:01 p.m. |
OK |
Java 11 |
TESTS |
71 |
888 |
0 |
|
2000 |
68674794 |
xodiac |
B |
Jan. 12, 2020, 6:08 p.m. |
OK |
Java 8 |
TESTS |
71 |
124 |
0 |
|
2000 |
68459794 |
Smir |
B |
Jan. 9, 2020, 5:39 p.m. |
OK |
Java 8 |
TESTS |
71 |
139 |
0 |
|
2000 |
68255318 |
fetetriste |
B |
Jan. 5, 2020, 2:33 p.m. |
OK |
Java 8 |
TESTS |
71 |
139 |
0 |
|
2000 |
68258240 |
iakovlev.zakhar |
B |
Jan. 5, 2020, 2:43 p.m. |
OK |
Java 8 |
TESTS |
71 |
140 |
0 |
|
2000 |
68466144 |
Smir |
B |
Jan. 9, 2020, 8:29 p.m. |
OK |
Java 8 |
TESTS |
71 |
140 |
0 |
|
2000 |
68258018 |
SecondThread |
B |
Jan. 5, 2020, 2:42 p.m. |
OK |
Java 8 |
TESTS |
71 |
140 |
0 |
|
2000 |
68255778 |
uwi |
B |
Jan. 5, 2020, 2:35 p.m. |
OK |
Java 8 |
TESTS |
71 |
140 |
0 |
|
2000 |
68265836 |
Harpae |
B |
Jan. 5, 2020, 3:14 p.m. |
OK |
Java 8 |
TESTS |
71 |
140 |
4403200 |
|
2000 |
68322247 |
ijxjdjd |
B |
Jan. 6, 2020, 3:25 p.m. |
OK |
Java 8 |
TESTS |
71 |
140 |
17305600 |
|
2000 |
68257195 |
cwise |
B |
Jan. 5, 2020, 2:39 p.m. |
OK |
Java 8 |
TESTS |
71 |
140 |
19456000 |
|
2000 |
68442255 |
AsuraPro |
B |
Jan. 9, 2020, 11:23 a.m. |
OK |
Kotlin |
TESTS |
71 |
187 |
1331200 |
|
2000 |
68265435 |
Tlatoani |
B |
Jan. 5, 2020, 3:12 p.m. |
OK |
Kotlin |
TESTS |
71 |
218 |
1228800 |
|
2000 |
68256417 |
knightL |
B |
Jan. 5, 2020, 2:37 p.m. |
OK |
Kotlin |
TESTS |
71 |
639 |
1433600 |
|
2000 |
68263840 |
mban259 |
B |
Jan. 5, 2020, 3:06 p.m. |
OK |
Mono C# |
TESTS |
71 |
62 |
26214400 |
|
2000 |
68382595 |
camypaper |
B |
Jan. 8, 2020, 3 a.m. |
OK |
Mono C# |
TESTS |
71 |
62 |
58572800 |
|
2000 |
68267302 |
r57shell |
B |
Jan. 5, 2020, 3:20 p.m. |
OK |
MS C++ |
TESTS |
71 |
31 |
409600 |
|
2000 |
68257230 |
math957963 |
B |
Jan. 5, 2020, 2:40 p.m. |
OK |
MS C++ |
TESTS |
71 |
31 |
6758400 |
|
2000 |
68262166 |
tarattata1 |
B |
Jan. 5, 2020, 2:59 p.m. |
OK |
MS C++ |
TESTS |
71 |
46 |
307200 |
|
2000 |
68584412 |
vjudge4 |
B |
Jan. 11, 2020, 10:53 a.m. |
OK |
MS C++ |
TESTS |
71 |
46 |
16281600 |
|
2000 |
68257355 |
pichulia |
B |
Jan. 5, 2020, 2:40 p.m. |
OK |
MS C++ 2017 |
TESTS |
71 |
31 |
102400 |
|
2000 |
68660401 |
sudha_18501 |
B |
Jan. 12, 2020, 1:28 p.m. |
OK |
MS C++ 2017 |
TESTS |
71 |
31 |
102400 |
|
2000 |
68270983 |
vpike |
B |
Jan. 5, 2020, 3:36 p.m. |
OK |
MS C++ 2017 |
TESTS |
71 |
31 |
307200 |
|
2000 |
68641508 |
18wh1a0546 |
B |
Jan. 12, 2020, 7:40 a.m. |
OK |
MS C++ 2017 |
TESTS |
71 |
31 |
307200 |
|
2000 |
68608123 |
varsha_18524 |
B |
Jan. 11, 2020, 2:44 p.m. |
OK |
MS C++ 2017 |
TESTS |
71 |
31 |
307200 |
|
2000 |
68273083 |
grey |
B |
Jan. 5, 2020, 3:44 p.m. |
OK |
MS C++ 2017 |
TESTS |
71 |
31 |
16486400 |
|
2000 |
68264406 |
Catmoonlight |
B |
Jan. 5, 2020, 3:08 p.m. |
OK |
MS C++ 2017 |
TESTS |
71 |
46 |
102400 |
|
2000 |
68304172 |
AleksanderBalobanov |
B |
Jan. 6, 2020, 8:15 a.m. |
OK |
MS C++ 2017 |
TESTS |
71 |
46 |
204800 |
|
2000 |
68589325 |
hakobdilif |
B |
Jan. 11, 2020, 12:13 p.m. |
OK |
MS C++ 2017 |
TESTS |
71 |
46 |
204800 |
|
2000 |
68274906 |
AlexanderL |
B |
Jan. 5, 2020, 3:52 p.m. |
OK |
MS C++ 2017 |
TESTS |
71 |
46 |
409600 |
|
2000 |
68284815 |
MVP |
B |
Jan. 5, 2020, 6:06 p.m. |
OK |
PyPy 2 |
TESTS |
71 |
187 |
2764800 |
|
2000 |
68284907 |
MVP |
B |
Jan. 5, 2020, 6:08 p.m. |
OK |
PyPy 2 |
TESTS |
71 |
202 |
2662400 |
|
2000 |
68284595 |
MVP |
B |
Jan. 5, 2020, 6:02 p.m. |
OK |
PyPy 2 |
TESTS |
71 |
218 |
3072000 |
|
2000 |
68744613 |
yumtam |
B |
Jan. 14, 2020, 3:46 a.m. |
OK |
PyPy 2 |
TESTS |
71 |
280 |
3379200 |
|
2000 |
68425310 |
srikanth.nettikanti |
B |
Jan. 9, 2020, 2:43 a.m. |
OK |
PyPy 3 |
TESTS |
71 |
186 |
10649600 |
|
2000 |
68425281 |
tycyd |
B |
Jan. 9, 2020, 2:41 a.m. |
OK |
PyPy 3 |
TESTS |
71 |
187 |
10649600 |
|
2000 |
68258024 |
pineriver |
B |
Jan. 5, 2020, 2:42 p.m. |
OK |
PyPy 3 |
TESTS |
71 |
218 |
14233600 |
|
2000 |
68944401 |
SinKing |
B |
Jan. 16, 2020, 3:35 p.m. |
OK |
PyPy 3 |
TESTS |
71 |
233 |
10035200 |
|
2000 |
68265372 |
cftt |
B |
Jan. 5, 2020, 3:12 p.m. |
OK |
PyPy 3 |
TESTS |
71 |
233 |
11264000 |
|
2000 |
68284095 |
titia |
B |
Jan. 5, 2020, 5:51 p.m. |
OK |
PyPy 3 |
TESTS |
71 |
280 |
11366400 |
|
2000 |
68268299 |
Kiri8128 |
B |
Jan. 5, 2020, 3:24 p.m. |
OK |
PyPy 3 |
TESTS |
71 |
576 |
64614400 |
|
2000 |
68354092 |
sayam.sethi2 |
B |
Jan. 7, 2020, 11:15 a.m. |
OK |
Python 3 |
TESTS |
71 |
124 |
1536000 |
|
2000 |
68260194 |
old_boo |
B |
Jan. 5, 2020, 2:51 p.m. |
OK |
Python 3 |
TESTS |
71 |
139 |
1536000 |
|
2000 |
68681495 |
xuanji |
B |
Jan. 12, 2020, 10:42 p.m. |
OK |
Python 3 |
TESTS |
71 |
140 |
1843200 |
|
2000 |
68681540 |
xuanji |
B |
Jan. 12, 2020, 10:46 p.m. |
OK |
Python 3 |
TESTS |
71 |
140 |
2252800 |
|
2000 |
68361106 |
_Kkura_ |
B |
Jan. 7, 2020, 2:07 p.m. |
OK |
Python 3 |
TESTS |
71 |
529 |
1945600 |
|
2000 |
68360727 |
_Kkura_ |
B |
Jan. 7, 2020, 1:59 p.m. |
OK |
Python 3 |
TESTS |
71 |
529 |
1945600 |
|
2000 |
68836152 |
qsqx |
B |
Jan. 15, 2020, 3:17 a.m. |
OK |
Rust |
TESTS |
71 |
31 |
1740800 |
|
2000 |
69088250 |
sansen |
B |
Jan. 19, 2020, 9:10 a.m. |
OK |
Rust |
TESTS |
71 |
46 |
204800 |
|
2000 |
69591640 |
qujun51319 |
B |
Jan. 27, 2020, 12:21 a.m. |
OK |
Rust |
TESTS |
71 |
46 |
409600 |
|
2000 |
68257991 |
ichyo |
B |
Jan. 5, 2020, 2:42 p.m. |
OK |
Rust |
TESTS |
71 |
62 |
1740800 |
|
2000 |
remove filters
Back to search problems