Codeforces Round 1023 (Div. 2)

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
2107 Codeforces Round 1023 (Div. 2) FINISHED False 8100 29949923 May 5, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 924 ) E Ain and Apple Tree PROGRAMMING constructive algorithms greedy math trees

If I was also hit by an apple falling from an apple tree, could I become as good at physics as Newton? To be better at physics, Ain wants to build an apple tree so that she can get hit by apples on it. Her apple tree has (n) nodes and is rooted at (1). She defines the weight of an apple tree as (\sum \limits_{i=1}^n \sum \limits_{j=i+1}^n \text{dep}(\operatorname{lca}(i,j))). Here, (\text{dep}(x)) is defined as the number of edges on the unique shortest path from node (1) to node (x). (\operatorname{lca}(i, j)) is defined as the unique node (x) with the largest value of (\text{dep}(x)) and which is present on both the paths ((1, i)) and ((1, j)). From some old books Ain reads, she knows that Newton's apple tree's weight is around (k), but the exact value of it is lost. As Ain's friend, you want to build an apple tree with (n) nodes for her, and the absolute difference between your tree's weight and (k) should be at most (1) , i.e. (|\text{weight} - k| \le 1). Unfortunately, this is not always possible, in this case please report it. 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 numbers (n,k) ((2 \le n \le 10^5,0 \le k \le 10^{15})). It is guaranteed that the sum of (n) over all test cases does not exceed (2 \cdot 10^5). For each test case, first output (Yes) if a solution exists or (No) if no solution exists. You may print each character in either case, for example (YES) and (yEs) will also be accepted. If there's at least one solution, print (n-1) lines and each line contains two numbers (u,v) ((1 \le u,v \le n)) represents the apple tree. In the first test case, we can check that the weight is (0). This satisfies the condition because (k = 1)

Tutorials

Codeforces Round 1023 (Div 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
318579322 Evan__Leo E May 6, 2025, 4:48 a.m. OK C++17 (GCC 7-32) TESTS 18 78 102400
318567728 SpinSpen E May 6, 2025, 12:53 a.m. OK C++17 (GCC 7-32) TESTS 18 93 0
318542540 rocky8474 E May 5, 2025, 6:15 p.m. OK C++17 (GCC 7-32) TESTS 18 93 102400
318527585 mertyilmaz E May 5, 2025, 4:47 p.m. OK C++17 (GCC 7-32) TESTS 18 93 102400
318548454 hw3901 E May 5, 2025, 7:18 p.m. OK C++17 (GCC 7-32) TESTS 18 108 614400
318572056 AythsrLL E May 6, 2025, 2:35 a.m. OK C++17 (GCC 7-32) TESTS 18 108 1638400
318528226 shorif274 E May 5, 2025, 4:48 p.m. OK C++17 (GCC 7-32) TESTS 18 108 2150400
318560758 urosk E May 5, 2025, 11:50 p.m. OK C++17 (GCC 7-32) TESTS 18 108 2457600
318551744 sichengzhou E May 5, 2025, 8:07 p.m. OK C++17 (GCC 7-32) TESTS 18 108 5120000
318526883 Kineeeee E May 5, 2025, 4:45 p.m. OK C++17 (GCC 7-32) TESTS 18 108 12083200
318578173 Pika E May 6, 2025, 4:27 a.m. OK C++20 (GCC 13-64) TESTS 18 62 0
318555284 mightyslavek E May 5, 2025, 9:07 p.m. OK C++20 (GCC 13-64) TESTS 18 62 0
318524787 beiyuli E May 5, 2025, 4:40 p.m. OK C++20 (GCC 13-64) TESTS 18 62 102400
318576565 xqqddqqc E May 6, 2025, 3:59 a.m. OK C++20 (GCC 13-64) TESTS 18 62 614400
318548866 liliwa E May 5, 2025, 7:24 p.m. OK C++20 (GCC 13-64) TESTS 18 62 35123200
318527428 physics0523 E May 5, 2025, 4:47 p.m. OK C++20 (GCC 13-64) TESTS 18 77 0
318523686 propane E May 5, 2025, 4:36 p.m. OK C++20 (GCC 13-64) TESTS 18 77 0
318544479 BaarishBoy E May 5, 2025, 6:34 p.m. OK C++20 (GCC 13-64) TESTS 18 77 614400
318521352 AnimeNaAve E May 5, 2025, 4:30 p.m. OK C++20 (GCC 13-64) TESTS 18 77 2252800
318545242 mathiasgw E May 5, 2025, 6:42 p.m. OK C++20 (GCC 13-64) TESTS 18 77 2457600
318570349 A_G E May 6, 2025, 1:55 a.m. OK C++23 (GCC 14-64, msys2) TESTS 18 62 0
318550882 BigBadBully E May 5, 2025, 7:53 p.m. OK C++23 (GCC 14-64, msys2) TESTS 18 62 0
318550868 SmallGoodNerd E May 5, 2025, 7:53 p.m. OK C++23 (GCC 14-64, msys2) TESTS 18 62 0
318540923 B_3 E May 5, 2025, 6 p.m. OK C++23 (GCC 14-64, msys2) TESTS 18 62 0
318572465 MeIoN_is_UMP45 E May 6, 2025, 2:42 a.m. OK C++23 (GCC 14-64, msys2) TESTS 18 62 102400
318561016 YuukiS E May 5, 2025, 11:59 p.m. OK C++23 (GCC 14-64, msys2) TESTS 18 62 102400
318545843 A_M_Namdar E May 5, 2025, 6:49 p.m. OK C++23 (GCC 14-64, msys2) TESTS 18 62 819200
318539603 B_3 E May 5, 2025, 5:49 p.m. OK C++23 (GCC 14-64, msys2) TESTS 18 77 0
318522604 whoooareyou E May 5, 2025, 4:33 p.m. OK C++23 (GCC 14-64, msys2) TESTS 18 77 0
318521947 gholyo E May 5, 2025, 4:31 p.m. OK C++23 (GCC 14-64, msys2) TESTS 18 77 0
318536208 muradbhai E May 5, 2025, 5:27 p.m. OK GNU C11 TESTS 18 905 102400
318581462 lyongwolf E May 6, 2025, 5:19 a.m. OK Java 21 TESTS 18 264 1433600
318521363 aditya72281 E May 5, 2025, 4:30 p.m. OK Java 21 TESTS 18 671 2252800
318524507 husc24.Serge_ E May 5, 2025, 4:39 p.m. OK Kotlin 1.7 TESTS 18 984 145305600
318520840 senpai404 E May 5, 2025, 4:28 p.m. OK Kotlin 1.9 TESTS 18 859 4608000
318581554 ValeriyShiyan E May 6, 2025, 5:20 a.m. OK PyPy 3-64 TESTS 18 187 9523200
318527072 IkeBarlow E May 5, 2025, 4:46 p.m. OK PyPy 3-64 TESTS 18 281 18329600
318525810 twosquares E May 5, 2025, 4:42 p.m. OK PyPy 3-64 TESTS 18 312 14131200
318527837 ProPTIT_MaiLinh E May 5, 2025, 4:48 p.m. OK PyPy 3-64 TESTS 18 312 18841600
318525217 dom7171 E May 5, 2025, 4:41 p.m. OK Rust 2021 TESTS 18 77 4812800
318526535 kira890 E May 5, 2025, 4:44 p.m. OK Rust 2021 TESTS 18 436 1536000

remove filters

Back to search problems