Codeforces Round 1076 (Div. 3)

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
2193 Codeforces Round 1076 (Div. 3) FINISHED False 8100 7053923 Jan. 25, 2026, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 1024 ) H Remove the Grail Tree PROGRAMMING dfs and similar dp greedy trees

The Great Grail Tree has stood in the kingdom for (315) years. It takes up a lot of space, so King Ila decided to get rid of it as soon as possible. The tree itself is an acyclic, connected, undirected graph with (n) vertices, each having its own value (a_v). The tree can be removed in the following way: Let (S_v) be the sum of the values of all remaining neighbors of (v). If (v) has no remaining neighbors, then (S_v) is (0). Choose a vertex (v) such that (a_v) and (S_v) differ in parity (i.e., either (a_v) is even and (S_v) is odd, or (a_v) is odd and (S_v) is even). If there are no such vertices, stop the process. Remove vertex (v) and all edges connected to it from the tree. Each test consists of several test case. The first line contains one integer (t) ((1\le t\le 10^4)) — the number of test cases. The description of the test cases follows. The first line contains the number (n) ((1\le n\le 2\cdot 10^5)) — the number of vertices in the Grail Tree. The second line describes the array (a) ((1\le a_i\le 10^9)) — the values of the vertices in the tree. Next, there are (n - 1) lines, each containing 2 numbers (v) and (u) ((1\le v, u\le n, v\neq u)), indicating that vertices (v) and (u) are connected by an edge in the tree. It is guaranteed that the sum of (n) across all test cases does not exceed (2\cdot 10^5). For each test case, output "YES" if it is possible to completely remove the Grail Tree. Otherwise, output "NO". If the answer is "YES", output any sequence of removals. You can output each letter in any case (lowercase or uppercase). For example, the strings "yEs", "yes", "Yes", and "YES" will be accepted as a positive answer.

Tutorials

Разбор Codeforces Round 1076 (Div. 3)

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
359922251 Taechka H Jan. 25, 2026, 10:47 p.m. OK C++17 (GCC 7-32) TESTS 35 234 7065600
359887360 lishuhang H Jan. 25, 2026, 4:53 p.m. OK C++17 (GCC 7-32) TESTS 35 250 14233600
359930073 Aerhuo H Jan. 26, 2026, 2:37 a.m. OK C++17 (GCC 7-32) TESTS 35 265 25088000
359925205 Bosha1 H Jan. 26, 2026, 12:22 a.m. OK C++17 (GCC 7-32) TESTS 35 312 14131200
359931408 ramumali2002 H Jan. 26, 2026, 3:04 a.m. OK C++17 (GCC 7-32) TESTS 35 312 20582400
359941348 ShadowSlayer1 H Jan. 26, 2026, 5:28 a.m. OK C++17 (GCC 7-32) TESTS 36 328 11776000
359923401 oYo H Jan. 25, 2026, 11:20 p.m. OK C++17 (GCC 7-32) TESTS 35 343 17408000
359892819 feresatcccccccc H Jan. 25, 2026, 5:29 p.m. OK C++17 (GCC 7-32) TESTS 35 343 23244800
359883429 ANUBHAV_INDIA H Jan. 25, 2026, 4:46 p.m. OK C++17 (GCC 7-32) TESTS 35 343 25395200
359933347 clawson19 H Jan. 26, 2026, 3:39 a.m. OK C++17 (GCC 7-32) TESTS 35 343 26316800
359890564 Inkyo H Jan. 25, 2026, 5:18 p.m. OK C++20 (GCC 13-64) TESTS 35 203 8601600
359919640 pokeland157 H Jan. 25, 2026, 9:47 p.m. OK C++20 (GCC 13-64) TESTS 35 203 12185600
359896319 LuOsIer H Jan. 25, 2026, 5:48 p.m. OK C++20 (GCC 13-64) TESTS 35 203 15155200
359884588 orz.-. H Jan. 25, 2026, 4:47 p.m. OK C++20 (GCC 13-64) TESTS 35 203 15155200
359888493 fisher199 H Jan. 25, 2026, 5:03 p.m. OK C++20 (GCC 13-64) TESTS 35 234 9318400
359914065 fanhuaxingyu H Jan. 25, 2026, 8:21 p.m. OK C++20 (GCC 13-64) TESTS 35 234 15155200
359938494 theRealChainman H Jan. 26, 2026, 4:57 a.m. OK C++20 (GCC 13-64) TESTS 36 234 37376000
359888016 fisher199 H Jan. 25, 2026, 4:59 p.m. OK C++20 (GCC 13-64) TESTS 35 250 9318400
359932067 toba H Jan. 26, 2026, 3:16 a.m. OK C++20 (GCC 13-64) TESTS 35 250 12697600
359892981 orz.-. H Jan. 25, 2026, 5:30 p.m. OK C++20 (GCC 13-64) TESTS 35 250 15155200
359925586 SparshMittal11 H Jan. 26, 2026, 12:35 a.m. OK C++23 (GCC 14-64, msys2) TESTS 35 156 7987200
359921385 n685 H Jan. 25, 2026, 10:25 p.m. OK C++23 (GCC 14-64, msys2) TESTS 35 203 15769600
359885626 fallleaves01 H Jan. 25, 2026, 4:48 p.m. OK C++23 (GCC 14-64, msys2) TESTS 35 203 32665600
359883332 Slient_Optimizer H Jan. 25, 2026, 4:46 p.m. OK C++23 (GCC 14-64, msys2) TESTS 35 218 35123200
359885985 Igor_2017 H Jan. 25, 2026, 4:49 p.m. OK C++23 (GCC 14-64, msys2) TESTS 35 234 9830400
359921616 NetFriendMutsumi H Jan. 25, 2026, 10:31 p.m. OK C++23 (GCC 14-64, msys2) TESTS 35 234 10342400
359921712 paula H Jan. 25, 2026, 10:33 p.m. OK C++23 (GCC 14-64, msys2) TESTS 35 234 15564800
359935236 Anemone_ H Jan. 26, 2026, 4:13 a.m. OK C++23 (GCC 14-64, msys2) TESTS 36 234 26009600
359942875 mnnit.prakharg H Jan. 26, 2026, 5:42 a.m. OK C++23 (GCC 14-64, msys2) TESTS 36 234 26419200
359932245 adam.jq.xu H Jan. 26, 2026, 3:20 a.m. OK C++23 (GCC 14-64, msys2) TESTS 35 234 27648000
359890453 pengin_2000 H Jan. 25, 2026, 5:17 p.m. OK GNU C11 TESTS 35 734 12083200
359902966 aha H Jan. 25, 2026, 6:31 p.m. OK Java 21 TESTS 35 453 6656000
359905621 krishankant30 H Jan. 25, 2026, 6:53 p.m. OK Java 21 TESTS 35 921 106905600
359939802 saisridhar.tarra H Jan. 26, 2026, 5:11 a.m. OK Java 21 TESTS 36 953 74137600
359925423 tin.le2 H Jan. 26, 2026, 12:30 a.m. OK Kotlin 2.2 TESTS 35 875 37888000
359925441 tin.le2 H Jan. 26, 2026, 12:30 a.m. OK Kotlin 2.2 TESTS 35 984 37785600
359917552 kaushik.atla H Jan. 25, 2026, 9:08 p.m. OK PyPy 3-64 TESTS 35 750 108953600
359908485 agloriousnoob H Jan. 25, 2026, 7:20 p.m. OK PyPy 3-64 TESTS 35 812 96358400
359918036 DeadMan69 H Jan. 25, 2026, 9:15 p.m. OK PyPy 3-64 TESTS 35 1156 241971200
359914083 allenchang2001 H Jan. 25, 2026, 8:21 p.m. OK Rust 2021 TESTS 35 187 50790400

remove filters

Back to search problems