Codeforces Round 681 (Div. 1, based on VK Cup 2019-2020 - Final)

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
1442 Codeforces Round 681 (Div. 1, based on VK Cup 2019-2020 - Final) FINISHED False 7200 132852263 Nov. 2, 2020, 2:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 627 ) E Black, White and Grey Tree PROGRAMMING dp trees

B"You are given a tree with each vertex coloured white, black or grey. You can remove elements from the tree by selecting a subset of vertices in a single connected component and removing them and their adjacent edges from the graph. The only restriction is that you are not allowed to select a subset containing a white and a black vertex at once. What is the minimum number of removals necessary to remove all vertices from the tree? Each test contains multiple test cases. The first line contains an integer t ( 1 <= t <= 100 ,000 ), denoting the number of test cases, followed by a description of the test cases. The first line of each test case contains an integer n ( 1 <= n <= 200 ,000 ): the number of vertices in the tree. The second line of each test case contains n integers a_v ( 0 <= a_v <= 2 ): colours of vertices. Gray vertices have a_v=0 , white have a_v=1 , black have a_v=2 . Each of the next n-1 lines contains two integers u, v ( 1 <= u, v <= n ): tree edges. The sum of all n throughout the test is guaranteed to not exceed 200 ,000 . For each test case, print one integer: the minimum number of operations to solve the problem. In the first test case, both vertices are white, so you can remove them at the same time. In the second test case, three operations are enough. First, we need to remove both black vertices (2 and 4), then separately remove vertices 1 and 3. We can't remove them together because they end up in different connectivity components after vertex 2 is removed. In the third test case, we can remove vertices 1, 2, 3, 4 at the same time, because three of them are white and one is grey. After that, we can remove vertex 5. In the fourth test case, three operations are enough. One of the ways to solve the problem is to remove all black vertices at once, then remove white vertex 7, and finally, remove connected white vertices 1 and 3. "...

Tutorials

84298

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
97494798 hos.lyric E Nov. 2, 2020, 5:15 p.m. OK D TESTS 60 405 24473600
97525092 Isonan E Nov. 3, 2020, 4:37 a.m. OK GNU C++11 TESTS 60 140 6758400
97518960 CN_zwang2002 E Nov. 3, 2020, 2:14 a.m. OK GNU C++11 TESTS 60 171 8089600
97479604 TadijaSebez E Nov. 2, 2020, 4:05 p.m. OK GNU C++11 TESTS 60 186 9728000
97516354 dqa2020 E Nov. 3, 2020, 12:43 a.m. OK GNU C++11 TESTS 60 530 9728000
97490693 LJC00118 E Nov. 2, 2020, 4:31 p.m. OK GNU C++11 TESTS 60 545 9728000
97518141 Argentina E Nov. 3, 2020, 1:47 a.m. OK GNU C++14 TESTS 60 234 11059200
97518516 Sooke E Nov. 3, 2020, 1:58 a.m. OK GNU C++14 TESTS 60 249 29081600
97489597 SoraMad E Nov. 2, 2020, 4:29 p.m. OK GNU C++14 TESTS 60 296 28057600
97519543 kmjp E Nov. 3, 2020, 2:31 a.m. OK GNU C++14 TESTS 60 623 26931200
97491110 LayCurse E Nov. 2, 2020, 4:32 p.m. OK GNU C++17 TESTS 60 78 103116800
97481313 lavenderwithbluish E Nov. 2, 2020, 4:09 p.m. OK GNU C++17 TESTS 60 187 7168000
97509112 VEGAnn E Nov. 2, 2020, 8:20 p.m. OK GNU C++17 TESTS 60 218 8294400
97501134 sh1194 E Nov. 2, 2020, 6:15 p.m. OK GNU C++17 TESTS 60 218 8294400
97503597 -XraY- E Nov. 2, 2020, 6:47 p.m. OK GNU C++17 TESTS 60 218 9830400
97482486 neckborov E Nov. 2, 2020, 4:12 p.m. OK GNU C++17 TESTS 60 218 9830400
97488473 Ra16bit E Nov. 2, 2020, 4:27 p.m. OK GNU C++17 TESTS 60 234 8294400
97498616 hank55663 E Nov. 2, 2020, 5:48 p.m. OK GNU C++17 TESTS 60 312 10137600
97516857 mibig E Nov. 3, 2020, 1:01 a.m. OK GNU C++17 TESTS 60 546 43520000
97512597 freak93 E Nov. 2, 2020, 9:54 p.m. OK GNU C++17 TESTS 60 623 10137600
97514122 LayCurse E Nov. 2, 2020, 10:59 p.m. OK GNU C++17 (64) TESTS 60 77 103116800
97528481 marX E Nov. 3, 2020, 5:43 a.m. OK GNU C++17 (64) TESTS 60 124 6860800
97521571 Frame233 E Nov. 3, 2020, 3:15 a.m. OK GNU C++17 (64) TESTS 60 139 7270400
97504562 risujiroh E Nov. 2, 2020, 7:01 p.m. OK GNU C++17 (64) TESTS 60 171 11878400
97483367 neal E Nov. 2, 2020, 4:14 p.m. OK GNU C++17 (64) TESTS 60 187 11059200
97487984 nuip E Nov. 2, 2020, 4:26 p.m. OK GNU C++17 (64) TESTS 60 202 12595200
97483183 gamegame E Nov. 2, 2020, 4:14 p.m. OK GNU C++17 (64) TESTS 60 202 12697600
97498243 kort0n E Nov. 2, 2020, 5:44 p.m. OK GNU C++17 (64) TESTS 60 217 16486400
97523545 wlzhouzhuan E Nov. 3, 2020, 4:01 a.m. OK GNU C++17 (64) TESTS 60 218 14540800
97475216 Benq E Nov. 2, 2020, 3:54 p.m. OK GNU C++17 (64) TESTS 60 233 13516800
97482905 uwi E Nov. 2, 2020, 4:13 p.m. OK Java 11 TESTS 60 342 13516800
97494860 mmaxio E Nov. 2, 2020, 5:16 p.m. OK Java 8 TESTS 60 171 5529600
97517752 cwise E Nov. 3, 2020, 1:34 a.m. OK Java 8 TESTS 60 389 39014400

remove filters

Back to search problems