Codeforces Global Round 27

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
2035 Codeforces Global Round 27 FINISHED False 10800 46365923 Oct. 27, 2024, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 1092 ) F Tree Operations PROGRAMMING binary search dfs and similar dp trees

One day, a turtle gives you a tree with (n) nodes rooted at node (x). Each node has an initial nonnegative value; the (i)-th node has starting value (a_i). You want to make the values of all nodes equal to (0). To do so, you will perform a series of operations on the tree, where each operation will be performed on a certain node. Define an operation on node (u) as choosing a single node in (u)'s subtree(^{\text{∗}}) and incrementing or decrementing its value by (1). The order in which operations are performed on nodes is as follows: For (1 \le i \le n), the (i)-th operation will be performed on node (i). For (i > n), the (i)-th operation will be performed on the same node as operation (i - n). More formally, the (i)-th operation will be performed on the ((((i - 1) \bmod n) + 1))-th node.(^{\text{†}}) Note that you cannot skip over operations; that is, you cannot perform the (i)-th operation without first performing operations (1, 2, \ldots, i - 1). Find the minimum number of operations you must perform before you can make the values of all nodes equal to (0), assuming you pick operations optimally. If it's impossible to make the values of all nodes equal to (0) after finite operations, output (-1). (^{\text{∗}})The subtree of a node (u) is the set of nodes for which (u) lies on the shortest path from this node to the root, including (u) itself. (^{\text{†}})Here, (a \bmod b) denotes the remainder from dividing (a) by (b). The first line contains a single integer (t) ((1\le t\le 100)) — the number of test cases. The first line of each test case contains two integers (n) and (x) ((1 \le n \le 2000), (1 \le x \le n)) — the number of nodes and the root of the tree. The second line of each test case contains (n) integers (a_1, a_2, \ldots, a_n) ((0 \le a_i \le 10^9)) — the starting value of each node. Ea

Tutorials

Codeforces Global Round 27 Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
288370349 leinad2 F Oct. 27, 2024, 5:25 p.m. OK C++17 (GCC 7-32) TESTS 18 156 102400
288406381 OdtreePrince F Oct. 28, 2024, 12:58 a.m. OK C++17 (GCC 7-32) TESTS 18 186 204800
288371523 OdtreePrince F Oct. 27, 2024, 5:28 p.m. OK C++17 (GCC 7-32) TESTS 18 202 102400
288368068 cfhj F Oct. 27, 2024, 5:19 p.m. OK C++17 (GCC 7-32) TESTS 18 233 102400
288364516 0wuming0 F Oct. 27, 2024, 5:09 p.m. OK C++17 (GCC 7-32) TESTS 18 234 204800
288361028 awu F Oct. 27, 2024, 4:59 p.m. OK C++17 (GCC 7-32) TESTS 18 264 102400
288360705 tolbi F Oct. 27, 2024, 4:58 p.m. OK C++17 (GCC 7-32) TESTS 18 281 102400
288364750 Enchom F Oct. 27, 2024, 5:10 p.m. OK C++17 (GCC 7-32) TESTS 18 749 204800
288368181 Muelsyse F Oct. 27, 2024, 5:20 p.m. OK C++17 (GCC 7-32) TESTS 18 1343 204800
288392250 sillylittleidiot77 F Oct. 27, 2024, 8:08 p.m. OK C++17 (GCC 7-32) TESTS 18 1421 102400
288364006 natsugiri F Oct. 27, 2024, 5:08 p.m. OK C++20 (GCC 13-64) TESTS 18 78 102400
288360411 LuCpp F Oct. 27, 2024, 4:57 p.m. OK C++20 (GCC 13-64) TESTS 18 108 102400
288407463 fishcathu. F Oct. 28, 2024, 1:26 a.m. OK C++20 (GCC 13-64) TESTS 18 109 102400
288407386 fishcathu. F Oct. 28, 2024, 1:24 a.m. OK C++20 (GCC 13-64) TESTS 18 124 102400
288368323 Silver_Fox F Oct. 27, 2024, 5:20 p.m. OK C++20 (GCC 13-64) TESTS 18 140 102400
288412439 orzdevinwang F Oct. 28, 2024, 3:10 a.m. OK C++20 (GCC 13-64) TESTS 19 155 44134400
288403113 Rvess F Oct. 27, 2024, 11:15 p.m. OK C++20 (GCC 13-64) TESTS 18 171 102400
288370265 TimDee F Oct. 27, 2024, 5:25 p.m. OK C++20 (GCC 13-64) TESTS 18 171 102400
288402995 Rvess F Oct. 27, 2024, 11:12 p.m. OK C++20 (GCC 13-64) TESTS 18 171 307200
288403013 Rvess F Oct. 27, 2024, 11:12 p.m. OK C++20 (GCC 13-64) TESTS 18 187 102400
288421194 _MASSIMO_ F Oct. 28, 2024, 5:23 a.m. OK C++23 (GCC 14-64, msys2) TESTS 19 124 44236800
288373916 lcyxds F Oct. 27, 2024, 5:33 p.m. OK C++23 (GCC 14-64, msys2) TESTS 18 140 102400
288365350 raincity F Oct. 27, 2024, 5:12 p.m. OK C++23 (GCC 14-64, msys2) TESTS 18 202 204800
288374780 IC1101 F Oct. 27, 2024, 5:34 p.m. OK C++23 (GCC 14-64, msys2) TESTS 18 203 32153600
288371939 penguinman F Oct. 27, 2024, 5:29 p.m. OK C++23 (GCC 14-64, msys2) TESTS 18 233 102400
288365632 jeroenodb F Oct. 27, 2024, 5:12 p.m. OK C++23 (GCC 14-64, msys2) TESTS 18 328 102400
288416962 husc24.Serge_ F Oct. 28, 2024, 4:22 a.m. OK C++23 (GCC 14-64, msys2) TESTS 19 343 102400
288366406 zlxFTH F Oct. 27, 2024, 5:15 p.m. OK C++23 (GCC 14-64, msys2) TESTS 18 358 102400
288378193 Dragnoid99 F Oct. 27, 2024, 6:08 p.m. OK C++23 (GCC 14-64, msys2) TESTS 18 609 102400
288409313 songke123 F Oct. 28, 2024, 2:09 a.m. OK C++23 (GCC 14-64, msys2) TESTS 18 624 204800
288392481 rainboy F Oct. 27, 2024, 8:11 p.m. OK GNU C11 TESTS 18 1217 204800
288379768 iakovlev.zakhar F Oct. 27, 2024, 6:19 p.m. OK Java 8 TESTS 18 2499 0
288360488 Nullptrs F Oct. 27, 2024, 4:57 p.m. OK PyPy 3-64 TESTS 18 1234 28979200
288402038 khuepr123 F Oct. 27, 2024, 10:44 p.m. OK PyPy 3-64 TESTS 18 2109 24371200
288401944 khuepr123 F Oct. 27, 2024, 10:42 p.m. OK PyPy 3-64 TESTS 18 2218 24371200
288371641 Z_actuary F Oct. 27, 2024, 5:29 p.m. OK PyPy 3-64 TESTS 18 3718 12800000
288370602 khuepr123 F Oct. 27, 2024, 5:26 p.m. OK PyPy 3-64 TESTS 18 3749 24268800
288403416 sansen F Oct. 27, 2024, 11:25 p.m. OK Rust 2021 TESTS 18 1811 409600

remove filters

Back to search problems