Codeforces Round 551 (Div. 2)

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.

ContestId
Name
Phase
Frozen
Duration (Seconds)
Relative Time
Start Time
1153 Codeforces Round 551 (Div. 2) FINISHED False 7200 182361323 April 13, 2019, 2:05 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 5061 ) D Serval and Rooted Tree PROGRAMMING binary search dfs and similar dp greedy trees 1800

B'Now Serval is a junior high school student in Japari Middle School, and he is still thrilled on math as before. As a talented boy in mathematics, he likes to play with numbers. This time, he wants to play with numbers on a rooted tree. A tree is a connected graph without cycles. A rooted tree has a special vertex called the root. A parent of a node v is the last different from v vertex on the path from the root to the vertex v . Children of vertex v are all nodes for which v is the parent. A vertex is a leaf if it has no children. The rooted tree Serval owns has n nodes, node 1 is the root. Serval will write some numbers into all nodes of the tree. However, there are some restrictions. Each of the nodes except leaves has an operation max or min written in it, indicating that the number in this node should be equal to the maximum or minimum of all the numbers in its sons, respectively. Assume that there are k leaves in the tree. Serval wants to put integers 1, 2, ldots, k to the k leaves (each number should be used exactly once). He loves large numbers, so he wants to maximize the number in the root. As his best friend, can you help him? The first line contains an integer n ( 2 <= q n <= q 3 cdot 10^5 ), the size of the tree. The second line contains n integers, the i -th of them represents the operation in the node i . 0 represents min and 1 represents max . If the node is a leaf, there is still a number of 0 or 1 , but you can ignore it. The third line contains n-1 integers f_2, f_3, ldots, f_n ( 1 <= q f_i <= q i-1 ), where f_i represents the parent of the node i . Output one integer -- the maximum possible number in the root of the tree. Pictures below explain the examples. The numbers written in the middle of the nodes are their indices, and the numbers written on the top are the numbers'...

Tutorials

Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
53437956 rr_ D April 27, 2019, 8:34 p.m. OK D TESTS 99 156 40243200 1800
53437862 rr_ D April 27, 2019, 8:30 p.m. OK D TESTS 99 171 39833600 1800
52699312 fluffyowl D April 13, 2019, 2:54 p.m. OK D TESTS 99 249 42188800 1800
52708928 iica D April 13, 2019, 3:39 p.m. OK D TESTS 99 327 57753600 1800
53470252 sansen D April 28, 2019, 12:23 p.m. OK GNU C11 TESTS 99 46 10752000 1800
52709033 4c5948 D April 13, 2019, 3:40 p.m. OK GNU C11 TESTS 99 140 9830400 1800
52700551 rainboy D April 13, 2019, 2:59 p.m. OK GNU C11 TESTS 99 171 13209600 1800
52727240 zhoushouchen D April 14, 2019, 1:38 a.m. OK GNU C++11 TESTS 99 46 7577600 1800
52698433 hangyesheng D April 13, 2019, 2:51 p.m. OK GNU C++11 TESTS 99 46 7987200 1800
63283611 luogu_bot4 D Oct. 24, 2019, 9:32 a.m. OK GNU C++11 TESTS 99 46 8601600 1800
52749378 y2823774827y D April 14, 2019, 1:17 p.m. OK GNU C++11 TESTS 99 46 9216000 1800
52749787 y2823774827y D April 14, 2019, 1:28 p.m. OK GNU C++11 TESTS 99 46 9216000 1800
53308945 luogu_bot2 D April 26, 2019, 5:01 a.m. OK GNU C++11 TESTS 99 46 9216000 1800
53308953 zekrom_dream D April 26, 2019, 5:01 a.m. OK GNU C++11 TESTS 99 46 9216000 1800
53599361 Enderwitherzjdl D May 1, 2019, 6:43 a.m. OK GNU C++11 TESTS 99 46 10240000 1800
52731118 Dilute D April 14, 2019, 4 a.m. OK GNU C++11 TESTS 99 46 11059200 1800
52744533 EncodeTalker D April 14, 2019, 10:56 a.m. OK GNU C++11 TESTS 99 46 11673600 1800
54098052 henry_y D May 14, 2019, 2:10 p.m. OK GNU C++14 TESTS 99 61 14950400 1800
67434932 wleung_bvg D Dec. 22, 2019, 4:44 p.m. OK GNU C++14 TESTS 99 93 14438400 1800
52746894 zjB_shadow D April 14, 2019, 12:07 p.m. OK GNU C++14 TESTS 99 93 15564800 1800
52705094 Eassion_C D April 13, 2019, 3:20 p.m. OK GNU C++14 TESTS 99 108 18124800 1800
59064505 kfqg D Aug. 19, 2019, 1:03 a.m. OK GNU C++14 TESTS 99 109 4812800 1800
52709140 H4XeO6 D April 13, 2019, 3:41 p.m. OK GNU C++14 TESTS 99 124 11878400 1800
52745358 osddeitf D April 14, 2019, 11:22 a.m. OK GNU C++14 TESTS 99 140 3584000 1800
52996420 wcl95716 D April 19, 2019, 4:12 a.m. OK GNU C++14 TESTS 99 140 4812800 1800
53050798 Mlxa D April 20, 2019, 2:30 p.m. OK GNU C++14 TESTS 99 140 6041600 1800
52733642 threepebbles D April 14, 2019, 5:22 a.m. OK GNU C++14 TESTS 99 140 11161600 1800
53116963 SharniR D April 22, 2019, 8:47 a.m. OK GNU C++17 TESTS 99 109 3584000 1800
52750788 AST_TheCoder D April 14, 2019, 1:55 p.m. OK GNU C++17 TESTS 99 109 4812800 1800
52751104 AST_TheCoder D April 14, 2019, 2:04 p.m. OK GNU C++17 TESTS 99 109 4812800 1800
52708386 nickluo D April 13, 2019, 3:37 p.m. OK GNU C++17 TESTS 99 124 14848000 1800
52796042 danielfleischman D April 15, 2019, 8:46 p.m. OK GNU C++17 TESTS 99 155 3686400 1800
58681528 alexradu04 D Aug. 12, 2019, 7:14 p.m. OK GNU C++17 TESTS 99 155 4812800 1800
52716781 markotee D April 13, 2019, 5:44 p.m. OK GNU C++17 TESTS 99 155 7270400 1800
53095671 _Kkura_ D April 21, 2019, 1:24 p.m. OK GNU C++17 TESTS 99 155 8396800 1800
53214179 201716080213 D April 24, 2019, 7:40 a.m. OK GNU C++17 TESTS 99 155 11980800 1800
53559911 jinli_ D April 30, 2019, 8:50 a.m. OK GNU C++17 TESTS 99 155 12697600 1800
52804358 2008061626 D April 16, 2019, 2:24 a.m. OK Go TESTS 99 421 27648000 1800
52755564 JHSN D April 14, 2019, 4:38 p.m. OK Go TESTS 99 452 23244800 1800
52708607 gksato D April 13, 2019, 3:38 p.m. OK Haskell TESTS 99 233 24268800 1800
52700380 StayAwayFromBitches D April 13, 2019, 2:59 p.m. OK Java 8 TESTS 99 187 13721600 1800
52985190 beroul D April 18, 2019, 6:39 p.m. OK Java 8 TESTS 99 202 14131200 1800
52718108 jenish9599 D April 13, 2019, 6:18 p.m. OK Java 8 TESTS 99 202 26521600 1800
52824559 hj5657 D April 16, 2019, 1:16 p.m. OK Java 8 TESTS 99 233 12288000 1800
54037627 Asgar D May 12, 2019, 3:28 p.m. OK Java 8 TESTS 99 248 23449600 1800
55093466 MarcosNavarrete D June 4, 2019, 3:46 p.m. OK Java 8 TESTS 99 265 12288000 1800
52701574 Taran_1407 D April 13, 2019, 3:04 p.m. OK Java 8 TESTS 99 265 26316800 1800
52709801 TheRaven D April 13, 2019, 3:44 p.m. OK Java 8 TESTS 99 296 17920000 1800
54512849 KharYusuf D May 23, 2019, 8:05 a.m. OK Java 8 TESTS 99 296 49868800 1800
52704894 Jeel_Vaishnav D April 13, 2019, 3:19 p.m. OK Java 8 TESTS 99 343 49049600 1800
54754802 retrograd D May 28, 2019, 2:31 p.m. OK Kotlin TESTS 99 530 26521600 1800
66252773 Tlatoani D Dec. 4, 2019, 3:32 a.m. OK Kotlin TESTS 99 670 0 1800
54023685 Asgar D May 12, 2019, 11:17 a.m. OK Kotlin TESTS 99 717 57446400 1800
54023428 Asgar D May 12, 2019, 11:08 a.m. OK Kotlin TESTS 99 717 57446400 1800
54748035 shubham__36 D May 28, 2019, 11:32 a.m. OK Kotlin TESTS 99 733 48844800 1800
52711923 Bobko D April 13, 2019, 3:55 p.m. OK Kotlin TESTS 99 857 83251200 1800
52739289 eki D April 14, 2019, 8:05 a.m. OK Mono C# TESTS 99 233 38604800 1800
58114961 NewLuminous D Aug. 1, 2019, 8:34 a.m. OK Mono C# TESTS 99 296 52940800 1800
52709001 keymoon D April 13, 2019, 3:40 p.m. OK Mono C# TESTS 99 374 50176000 1800
52911811 camypaper D April 17, 2019, 2:22 p.m. OK Mono C# TESTS 99 451 28876800 1800
52711639 kuuso D April 13, 2019, 3:54 p.m. OK Mono C# TESTS 99 483 47104000 1800
52920809 fr0st D April 17, 2019, 5:45 p.m. OK Mono C# TESTS 99 545 118784000 1800
60750065 vjudge1 D Sept. 18, 2019, 5:39 a.m. OK MS C++ TESTS 99 124 11264000 1800
54755615 scorpiowf D May 28, 2019, 2:44 p.m. OK MS C++ TESTS 99 124 13619200 1800
63532473 vjudge1 D Oct. 27, 2019, 7:07 a.m. OK MS C++ TESTS 99 140 9625600 1800
52728608 wjfwjfwjf D April 14, 2019, 2:34 a.m. OK MS C++ TESTS 99 155 13312000 1800
57640617 vjudge1 D July 24, 2019, 12:29 p.m. OK MS C++ TESTS 99 156 11366400 1800
63528977 vjudge2 D Oct. 27, 2019, 6:09 a.m. OK MS C++ TESTS 99 156 15360000 1800
53081157 hyacinthusorientalis D April 21, 2019, 6:34 a.m. OK MS C++ TESTS 99 171 11878400 1800
53174413 qcwlmqy D April 23, 2019, 2:16 a.m. OK MS C++ TESTS 99 171 11878400 1800
63269785 vjudge4 D Oct. 24, 2019, 3:12 a.m. OK MS C++ TESTS 99 171 14131200 1800
52706379 oi000 D April 13, 2019, 3:26 p.m. OK MS C++ TESTS 99 187 12697600 1800
52776455 2465806616 D April 15, 2019, 12:14 p.m. OK MS C++ 2017 TESTS 99 186 7065600 1800
52915686 GOATWU D April 17, 2019, 3:45 p.m. OK MS C++ 2017 TESTS 99 186 11264000 1800
53706254 R99 D May 3, 2019, 1:20 p.m. OK MS C++ 2017 TESTS 99 202 11673600 1800
52774145 petko_mitkov D April 15, 2019, 11:03 a.m. OK MS C++ 2017 TESTS 99 218 10342400 1800
52818080 hwangganzi D April 16, 2019, 10:36 a.m. OK MS C++ 2017 TESTS 99 218 12492800 1800
52708440 work_hard. D April 13, 2019, 3:37 p.m. OK MS C++ 2017 TESTS 99 233 11673600 1800
53023171 CtrlAlt D April 19, 2019, 5:32 p.m. OK MS C++ 2017 TESTS 99 234 12083200 1800
52740175 AleksanderBalobanov D April 14, 2019, 8:35 a.m. OK MS C++ 2017 TESTS 99 265 34099200 1800
52713463 DWAE86 D April 13, 2019, 4:03 p.m. OK MS C++ 2017 TESTS 99 295 16896000 1800
57600409 pmitkov D July 23, 2019, 3:33 p.m. OK MS C++ 2017 TESTS 99 342 14028800 1800
58532520 _MIT D Aug. 10, 2019, 10:14 a.m. OK PyPy 2 TESTS 99 342 29286400 1800
58532574 vjudge1 D Aug. 10, 2019, 10:16 a.m. OK PyPy 2 TESTS 99 358 29286400 1800
52723420 pajenegod D April 13, 2019, 9:29 p.m. OK PyPy 2 TESTS 99 498 33177600 1800
53016835 gatsko D April 19, 2019, 2:33 p.m. OK PyPy 2 TESTS 99 608 41472000 1800
55381965 homoeconomicus D June 9, 2019, 9:36 p.m. OK PyPy 3 TESTS 99 390 30310400 1800
53495188 sdhd D April 29, 2019, 11:22 a.m. OK PyPy 3 TESTS 99 468 52838400 1800
52727664 saku7 D April 14, 2019, 1:58 a.m. OK PyPy 3 TESTS 99 514 35532800 1800
53435226 sdhd D April 27, 2019, 6:43 p.m. OK PyPy 3 TESTS 99 514 52736000 1800
52715415 meooow D April 13, 2019, 5:22 p.m. OK PyPy 3 TESTS 99 545 52838400 1800
52928103 DomiKo D April 17, 2019, 10:27 p.m. OK PyPy 3 TESTS 99 561 35737600 1800
52717006 meooow D April 13, 2019, 5:49 p.m. OK PyPy 3 TESTS 99 576 46899200 1800
52708906 Aleshkevich D April 13, 2019, 3:39 p.m. OK PyPy 3 TESTS 99 577 42086400 1800
52740393 Kiri8128 D April 14, 2019, 8:41 a.m. OK PyPy 3 TESTS 99 592 42598400 1800
53495177 sdhd D April 29, 2019, 11:22 a.m. OK PyPy 3 TESTS 99 592 48742400 1800
52718241 Helli.code D April 13, 2019, 6:21 p.m. OK Python 2 TESTS 99 904 34713600 1800
57700357 pa.n.ik D July 24, 2019, 5:40 p.m. OK Python 2 TESTS 99 935 144691200 1800
52714961 pa.n.ik D April 13, 2019, 5:18 p.m. OK Python 2 TESTS 99 982 145100800 1800
52915028 codershuvo D April 17, 2019, 3:30 p.m. OK Python 3 TESTS 99 779 35737600 1800
52717927 changz D April 13, 2019, 6:14 p.m. OK Python 3 TESTS 99 826 38400000 1800
53495208 sdhd D April 29, 2019, 11:23 a.m. OK Python 3 TESTS 99 826 41779200 1800
53435283 sdhd D April 27, 2019, 6:46 p.m. OK Python 3 TESTS 99 826 41779200 1800
53495212 sdhd D April 29, 2019, 11:23 a.m. OK Python 3 TESTS 99 826 50688000 1800
52728722 Kiri8128 D April 14, 2019, 2:38 a.m. OK Python 3 TESTS 99 857 38707200 1800
53435238 sdhd D April 27, 2019, 6:44 p.m. OK Python 3 TESTS 99 857 50688000 1800
65232783 wattaihei D Nov. 17, 2019, 5:54 a.m. OK Python 3 TESTS 99 857 212889600 1800
56050060 vardisperi_spilo_69 D June 25, 2019, 6:34 p.m. OK Python 3 TESTS 99 872 38400000 1800
52729112 Kiri8128 D April 14, 2019, 2:51 a.m. OK Python 3 TESTS 99 873 35737600 1800
52723675 rinzu D April 13, 2019, 9:42 p.m. OK Ruby TESTS 99 639 68300800 1800
53282612 sash0 D April 25, 2019, 12:38 p.m. OK Rust TESTS 99 202 19558400 1800
52751333 kobae964 D April 14, 2019, 2:12 p.m. OK Rust TESTS 99 249 12800000 1800
62566344 yakamoto D Oct. 14, 2019, 1:20 p.m. OK Scala TESTS 99 717 41574400 1800

remove filters

Back to search problems