Codeforces Round 1020 (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
2106 Codeforces Round 1020 (Div. 3) FINISHED False 8100 30900323 April 24, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 604 ) G2 Baudelaire (hard version) PROGRAMMING binary search dfs and similar divide and conquer implementation interactive trees

This is the Hard Version of the problem. The only difference between the two versions is that in the Hard Version the tree may be of any shape. This problem is interactive. Baudelaire is very rich, so he bought a tree of size (n), rooted at some arbitrary node. Additionally, every node has a value of (1) or (-1). Cow the Nerd saw the tree and fell in love with it. However, computer science doesn't pay him enough, so he can't afford to buy it. Baudelaire decided to play a game with Cow the Nerd, and if he won, he would gift him the tree. Cow the Nerd does not know which node is the root, and he doesn't know the values of the nodes either. However, he can ask Baudelaire queries of two types: (1) (k) (u_1) (u_2) (...) (u_k): Let (f(u)) be the sum of the values of all nodes in the path from the root of the tree to node (u). Cow the Nerd may choose an integer (k) ((1 \le k \le n)) and (k) nodes (u_1, u_2, ..., u_k), and he will receive the value (f(u_1) + f(u_2) + ... + f(u_k)). (2) (u): Baudelaire will toggle the value of node (u). Specifically, if the value of (u) is (1), it will become (-1), and vice versa. Cow the Nerd wins if he guesses the value of every node correctly (the values of the final tree, after performing the queries) within (n + 200) total queries. Can you help him win? The first line of the input contains a single integer (t) ((1 \le t \le 100)), the number of test cases. The first line of each test case contains a single integer (n) ((2 \le n \le 10^3)), the size of the tree. Each of the next (n-1) lines contains two integers (u) and (v) ((1 \le u, v \le n, u \neq v)), denoting an edge between nodes (u) and (v) in the tree. It is guaranteed that the sum of (n) over all test cases does not exceed (10^3) and that each graph provided is a valid tree. To ask a query of type (1), output a line in the foll

Tutorials

Codeforces Round 1020 (Div. 3) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
317082851 -firefly- G2 April 24, 2025, 5:18 p.m. OK C# 10 TESTS 43 234 5120000
317129300 zxh923 G2 April 25, 2025, 4:54 a.m. OK C++17 (GCC 7-32) TESTS 43 77 102400
317127695 sardor_1 G2 April 25, 2025, 4:29 a.m. OK C++17 (GCC 7-32) TESTS 43 77 102400
317127099 hxano G2 April 25, 2025, 4:19 a.m. OK C++17 (GCC 7-32) TESTS 43 77 102400
317124463 11490DX G2 April 25, 2025, 3:31 a.m. OK C++17 (GCC 7-32) TESTS 43 77 102400
317083999 Jr-zlw G2 April 24, 2025, 5:26 p.m. OK C++17 (GCC 7-32) TESTS 43 77 102400
317075450 StarSilk G2 April 24, 2025, 4:46 p.m. OK C++17 (GCC 7-32) TESTS 43 77 102400
317079097 Seto-Kaiba G2 April 24, 2025, 4:55 p.m. OK C++17 (GCC 7-32) TESTS 43 77 8908800
317125495 zyb_txdy G2 April 25, 2025, 3:49 a.m. OK C++17 (GCC 7-32) TESTS 43 78 6041600
317103311 GNBElover G2 April 24, 2025, 8:31 p.m. OK C++17 (GCC 7-32) TESTS 43 92 102400
317080671 rika G2 April 24, 2025, 5:04 p.m. OK C++17 (GCC 7-32) TESTS 43 93 0

remove filters

Back to search problems