Codeforces Round 1046 (Div. 1)

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
2135 Codeforces Round 1046 (Div. 1) FINISHED False 10800 20013923 Aug. 28, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 242 ) F To the Infinity PROGRAMMING data structures hashing math trees

You are given a full binary tree(^{\text{∗}}) of (n) nodes, rooted at node (1). For each node (u) ((1\le u\le n)), we define function (f_u : \mathbb R_+ \to \mathbb R_+) as follows: If (u) is a leaf(^{\text{†}}), then (f_u(x)=x); Otherwise, denote the left child of (u) as (l_u) and the right child of (u) as (r_u), then (f_u(x)=(f_{l_u}(x))^{f_{r_u}(x)}). For two nodes (u) and (v), we say (u\prec v) if and only if one of the following holds: (f_{u}(x) N), (f_u(x) < f_v(x)) holds. The same is defined for (f_u(x) = f_v(x)) when (x\to \infty). (^{\text{§}})A permutation of length (n) is an array consisting of (n) distinct integers from (1) to (n) in arbitrary order. For example, (2,3,1,5,4) is a permutation, but (1,2,2) is not a permutation ((2) appears twice in the array), and (1,3,4) is also not a permutation ((n=3) but there is (4) in the array). Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 10^4)). The description of the test cases follows. The first line of each test case contains a single integer (n) ((1\le n \le 4\cdot 10^5), (n) is odd) — the size of the full binary tree. Then (n) lines follow, the (i)-th line containing two integers (l_i) and (r_i) ((0\le l_i, r_i\le n)) — the left child and the right child of node (i). If (i) is a leaf, then (l_i=r_i=0). It is guaranteed that the given input forms a full binary tree rooted at node (1). It is guaranteed that the sum of (n) over all test cases does not exceed (4\cdot 10^5). For each test case, output (n) integers (p_1, p_2, \ldots, p_n) ((1\le p_i\le n), all (p_i) are distinct) — the permutation you found. You need to guarantee that for each (1\le i < n), (p_i\prec p_{i+1}). In the first test case, (f_2(x)=f_3(x)=x), and

Tutorials

Codeforces Round 1046 (Div. 1, Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
336085966 qiuzx F Aug. 29, 2025, 5:27 a.m. OK C++20 (GCC 13-64) TESTS 33 1109 142745600
336052549 Tlatoani F Aug. 28, 2025, 7:36 p.m. OK C++20 (GCC 13-64) TESTS 33 1327 219648000
336036408 ecnerwala F Aug. 28, 2025, 5:13 p.m. OK C++23 (GCC 14-64, msys2) TESTS 33 546 289996800
336088608 Ayushbanacoder F Aug. 29, 2025, 5:55 a.m. OK C++23 (GCC 14-64, msys2) TESTS 33 671 122572800
336084571 Ab_hoga_real_Cumback F Aug. 29, 2025, 5:13 a.m. OK C++23 (GCC 14-64, msys2) TESTS 33 702 121651200
336043177 jiangly F Aug. 28, 2025, 5:32 p.m. OK C++23 (GCC 14-64, msys2) TESTS 33 702 121651200
336032842 ksun48 F Aug. 28, 2025, 5:03 p.m. OK C++23 (GCC 14-64, msys2) TESTS 33 702 947609600
336042961 Nyaan F Aug. 28, 2025, 5:31 p.m. OK C++23 (GCC 14-64, msys2) TESTS 33 843 496332800
336061062 kaiboy F Aug. 28, 2025, 9:31 p.m. OK C++23 (GCC 14-64, msys2) TESTS 33 1217 144281600
336002844 rainboy F Aug. 28, 2025, 3:51 p.m. OK C++23 (GCC 14-64, msys2) TESTS 33 1359 174796800
336052994 hos.lyric F Aug. 28, 2025, 7:40 p.m. OK C++23 (GCC 14-64, msys2) TESTS 33 1656 569344000

remove filters

Back to search problems