Codeforces Round 1048 (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
2138 Codeforces Round 1048 (Div. 1) FINISHED False 10800 19063523 Sept. 8, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 3340 ) C2 Maple and Tree Beauty (Hard Version) PROGRAMMING bitmasks brute force dfs and similar divide and conquer dp fft trees

This is the hard version of the problem. The difference between the versions is that in this version, the constraints on (t) and (n) are larger. You can hack only if you solved all versions of this problem. Maple is given a rooted tree consisting of (n) vertices numbered from (1) to (n), where the root has index (1). Each vertex of the tree is labeled either zero or one. Unfortunately, Maple forgot how the vertices are labeled and only remembers that there are exactly (k) zeros and (n - k) ones. For each vertex, we define the name of the vertex as the binary string formed by concatenating the labels of the vertices from the root to the vertex. More formally, (\text{name}_1 = \text{label}_1) and (\text{name}_u = \text{name}_{p_u} + \text{label}_u) for all (2\le u\le n), where (p_u) is the parent of vertex (u) and (+) represents string concatenation. The beauty of the tree is equal to the length of the longest common subsequence(^{\text{∗}}) of the names of all the leaves (^{\text{†}}). Your task is to determine the maximum beauty among all labelings of the tree with exactly (k) zeros and (n - k) ones. (^{\text{∗}})A sequence (a) is a subsequence of a sequence (b) if (a) can be obtained from (b) by the deletion of several (possibly, zero or all) element from arbitrary positions. The longest common subsequence of strings (s_1, s_2, \ldots s_m) is the longest string that is a subsequence of all of (s_1, s_2, \ldots, s_m). (^{\text{†}})A leaf is any vertex without children. 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 two integers (n) and (k) ((2 \leq n \leq 2\cdot 10 ^ 5), (0 \leq k \leq n)) — the number of vertices and the number of vertices labelled with zero, respectively. The se

Tutorials

Codeforces Round 1048 (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
337617133 fengqiyuka C2 Sept. 8, 2025, 3:47 p.m. OK C++17 (GCC 7-32) TESTS 62 124 1638400
337618208 DizzyGroovy C2 Sept. 8, 2025, 3:49 p.m. OK C++17 (GCC 7-32) TESTS 62 124 2560000
337685070 SpecterTheUnchained C2 Sept. 9, 2025, 12:43 a.m. OK C++17 (GCC 7-32) TESTS 67 124 4403200
337611142 Sai_t C2 Sept. 8, 2025, 3:36 p.m. OK C++17 (GCC 7-32) TESTS 62 124 5222400
337637739 DarksideWanderer C2 Sept. 8, 2025, 4:30 p.m. OK C++17 (GCC 7-32) TESTS 62 124 9625600
337648065 PoPularPlusPlus C2 Sept. 8, 2025, 4:56 p.m. OK C++17 (GCC 7-32) TESTS 62 124 400793600
337692723 8Conan8 C2 Sept. 9, 2025, 3:02 a.m. OK C++17 (GCC 7-32) TESTS 67 125 5632000
337635063 as_dfsdf C2 Sept. 8, 2025, 4:23 p.m. OK C++17 (GCC 7-32) TESTS 62 139 28364800
337625964 Elaina C2 Sept. 8, 2025, 4:04 p.m. OK C++17 (GCC 7-32) TESTS 62 140 4096000
337622243 catforces C2 Sept. 8, 2025, 3:56 p.m. OK C++17 (GCC 7-32) TESTS 62 140 4403200
337638024 wangjinbo C2 Sept. 8, 2025, 4:30 p.m. OK C++20 (GCC 13-64) TESTS 62 93 4198400
337605806 physics0523 C2 Sept. 8, 2025, 3:27 p.m. OK C++20 (GCC 13-64) TESTS 62 108 102400
337610595 E_fireworks C2 Sept. 8, 2025, 3:35 p.m. OK C++20 (GCC 13-64) TESTS 62 108 7577600
337607391 bachbach2007 C2 Sept. 8, 2025, 3:30 p.m. OK C++20 (GCC 13-64) TESTS 62 109 1024000
337608141 SSKMF C2 Sept. 8, 2025, 3:31 p.m. OK C++20 (GCC 13-64) TESTS 62 109 2867200
337606024 EnuTieTie C2 Sept. 8, 2025, 3:28 p.m. OK C++20 (GCC 13-64) TESTS 62 109 4096000
337645532 chen_zida C2 Sept. 8, 2025, 4:49 p.m. OK C++20 (GCC 13-64) TESTS 62 109 5632000
337584484 gamegame C2 Sept. 8, 2025, 2:57 p.m. OK C++20 (GCC 13-64) TESTS 62 109 56115200
337696505 ywc_ C2 Sept. 9, 2025, 3:56 a.m. OK C++20 (GCC 13-64) TESTS 68 124 102400
337687831 classic C2 Sept. 9, 2025, 1:42 a.m. OK C++20 (GCC 13-64) TESTS 67 124 102400
337684135 424479543 C2 Sept. 9, 2025, 12:24 a.m. OK C++23 (GCC 14-64, msys2) TESTS 67 92 9625600
337604487 26100154 C2 Sept. 8, 2025, 3:25 p.m. OK C++23 (GCC 14-64, msys2) TESTS 62 92 9625600
337647331 LoboLobo C2 Sept. 8, 2025, 4:54 p.m. OK C++23 (GCC 14-64, msys2) TESTS 62 93 4096000
337636934 Void_Wu C2 Sept. 8, 2025, 4:28 p.m. OK C++23 (GCC 14-64, msys2) TESTS 62 108 307200
337601221 Nyaan C2 Sept. 8, 2025, 3:20 p.m. OK C++23 (GCC 14-64, msys2) TESTS 62 108 1024000
337597760 rubbishZ C2 Sept. 8, 2025, 3:15 p.m. OK C++23 (GCC 14-64, msys2) TESTS 62 108 3686400
337608118 cdxcdxcdxcdx C2 Sept. 8, 2025, 3:31 p.m. OK C++23 (GCC 14-64, msys2) TESTS 62 108 50585600
337605017 DiMashina2005 C2 Sept. 8, 2025, 3:26 p.m. OK C++23 (GCC 14-64, msys2) TESTS 62 109 102400
337581545 jiangly C2 Sept. 8, 2025, 2:54 p.m. OK C++23 (GCC 14-64, msys2) TESTS 62 109 307200
337632732 ace5 C2 Sept. 8, 2025, 4:18 p.m. OK C++23 (GCC 14-64, msys2) TESTS 62 109 1024000
337657685 pengin_2000 C2 Sept. 8, 2025, 5:25 p.m. OK GNU C11 TESTS 62 92 7270400
337671698 MaxBuzz C2 Sept. 8, 2025, 7:53 p.m. OK Java 21 TESTS 63 2546 1228800
337614692 iakovlev.zakhar C2 Sept. 8, 2025, 3:42 p.m. OK Java 8 TESTS 62 218 4915200
337601237 sunnydev C2 Sept. 8, 2025, 3:20 p.m. OK Java 8 TESTS 62 1171 0
337616262 golomb C2 Sept. 8, 2025, 3:45 p.m. OK PyPy 3-64 TESTS 62 374 26009600
337628804 twosquares C2 Sept. 8, 2025, 4:09 p.m. OK PyPy 3-64 TESTS 62 390 49868800
337623706 eepsilon C2 Sept. 8, 2025, 3:59 p.m. OK PyPy 3-64 TESTS 62 499 36249600
337620886 Z_actuary C2 Sept. 8, 2025, 3:54 p.m. OK PyPy 3-64 TESTS 62 515 77414400
337628394 ow3nL C2 Sept. 8, 2025, 4:09 p.m. OK PyPy 3-64 TESTS 62 1062 35737600
337640460 LMeyling C2 Sept. 8, 2025, 4:36 p.m. OK PyPy 3-64 TESTS 62 2187 66764800
337685686 alexwice C2 Sept. 9, 2025, 12:57 a.m. OK PyPy 3-64 TESTS 67 3390 52736000
337601175 sansen C2 Sept. 8, 2025, 3:20 p.m. OK Rust 2021 TESTS 62 218 18636800
337593372 Sugar_fan C2 Sept. 8, 2025, 3:08 p.m. OK Rust 2024 TESTS 62 749 3993600
337644372 Ming_Xu C2 Sept. 8, 2025, 4:46 p.m. OK Rust 2024 TESTS 62 1577 60108800

remove filters

Back to search problems