Codeforces Round 949 (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
1981 Codeforces Round 949 (Div. 2) FINISHED False 7200 20030063 May 31, 2024, 10:05 a.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 286 ) F Turtle and Paths on a Tree PROGRAMMING data structures dp trees

B'Note the unusual definition of text{MEX} in this problem. Piggy gave Turtle a binary tree ^{ dagger} with n vertices and a sequence a_1, a_2, ldots, a_n on his birthday. The binary tree is rooted at vertex 1 . If a set of paths P = {(x_i, y_i) } in the tree covers each edge exactly once, then Turtle will think that the set of paths is good. Note that a good set of paths can cover a vertex twice or more. Turtle defines the value of a set of paths as sum limits_{(x, y) in P} f(x, y) , where f(x, y) denotes the text{MEX}^{ ddagger} of all a_u such that vertex u is on the simple path from x to y in the tree (including the starting vertex x and the ending vertex y ). Turtle wonders the minimum value over all good sets of paths. Please help him calculate the answer! ^{ dagger} A binary tree is a tree where every non-leaf vertex has at most 2 sons. ^{ ddagger} text{MEX} of a collection of integers c_1, c_2, ldots, c_k is defined as the smallest positive integer x which does not occur in the collection c . For example, text{MEX} of [3, 3, 1, 4] is 2 , text{MEX} of [2, 3] is 1 . Each test contains multiple test cases. The first line contains the number of test cases t ( 1 <= t <= 10^4 ). The description of the test cases follows. The first line of each test case contains a single integer n ( 2 <= n <= 2.5 cdot 10^4 ) -- the number of vertices in the tree. The second line of each test case contains n integers a_1, a_2, ldots, a_n ( 1 <= a_i <= 10^9 ) -- the elements of the sequence a . The third line of each test case contains n - 1 integers p_2, p_3, ldots, p_n ( 1 <= p_i < i ) -- the parent of each vertex in the tree. Additional constraint on the input: the given tree is a binary tree, that is, every non-leaf vertex has at most 2 '...

Tutorials

Simplified Chinese Tutorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
263561106 LG805653 F June 1, 2024, 1:28 a.m. OK C++14 (GCC 6-32) TESTS 57 1405 429260800
263601171 Mapakaka F June 1, 2024, 8:47 a.m. OK C++14 (GCC 6-32) TESTS 57 1624 401715200
263693923 Drlobster F June 2, 2024, 3:03 a.m. OK C++17 (GCC 7-32) TESTS 57 1015 402022400
263547114 VIVEKSHAH786 F May 31, 2024, 8:06 p.m. OK C++17 (GCC 7-32) TESTS 57 1108 402022400
263625616 bibabu F June 1, 2024, 12:01 p.m. OK C++17 (GCC 7-32) TESTS 57 1514 378982400
263567730 bibabu F June 1, 2024, 3:22 a.m. OK C++17 (GCC 7-32) TESTS 57 1515 378982400
263637991 zszc F June 1, 2024, 1:49 p.m. OK C++17 (GCC 7-32) TESTS 57 1515 401408000
263689475 Md._Nahid_Ullah_Joy F June 2, 2024, 1:17 a.m. OK C++17 (GCC 7-32) TESTS 57 2093 401203200
263524690 yasseinhamdy15 F May 31, 2024, 4:15 p.m. OK C++17 (GCC 7-32) TESTS 57 3046 438988800
263586716 sudarshan9975__satya F June 1, 2024, 6:47 a.m. OK C++17 (GCC 7-32) TESTS 57 3203 775680000
263579356 Sparkle_Twilight F June 1, 2024, 5:41 a.m. OK C++17 (GCC 7-32) TESTS 57 3203 775680000
263577922 2210030020m F June 1, 2024, 5:25 a.m. OK C++17 (GCC 7-32) TESTS 57 3203 775680000
263519100 mario.locaus F May 31, 2024, 3:26 p.m. OK C++20 (GCC 13-64) TESTS 57 234 337408000
263555946 luogu_bot5 F May 31, 2024, 11:10 p.m. OK C++20 (GCC 13-64) TESTS 57 1078 402329600
263504407 Engineer F May 31, 2024, 1:24 p.m. OK C++20 (GCC 13-64) TESTS 57 1124 402329600
263503592 aklk1ng F May 31, 2024, 1:17 p.m. OK C++20 (GCC 13-64) TESTS 57 1124 402329600
263570390 zltzlt F June 1, 2024, 3:54 a.m. OK C++20 (GCC 13-64) TESTS 57 1171 402329600
263594080 thomaswmy F June 1, 2024, 7:48 a.m. OK C++20 (GCC 13-64) TESTS 57 1202 402432000
263594025 thomaswmy F June 1, 2024, 7:48 a.m. OK C++20 (GCC 13-64) TESTS 57 1202 402432000
263497142 cyb0101 F May 31, 2024, 12:30 p.m. OK C++20 (GCC 13-64) TESTS 57 1234 402227200
263624192 luogu_bot1 F June 1, 2024, 11:50 a.m. OK C++20 (GCC 13-64) TESTS 57 1264 401408000
263663100 re-wa-tl-ok F June 1, 2024, 5:23 p.m. OK C++20 (GCC 13-64) TESTS 57 1265 400896000

remove filters

Back to search problems