Codeforces Round 1118 (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
2258 Codeforces Round 1118 (Div. 2) FINISHED False 7200 141884 Aug. 29, 2026, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 3503 ) C Far Cities PROGRAMMING interactive trees two pointers

This is an interactive problem. Seferoglu lives in a small coastal city called Samsun, a city where not many people study competitive programming. Whenever an event takes place, he has to travel to far cities where he can meet his friends. Since he is tired of calculating the length of his journey exactly each time, he is just curious about the maximum distance he will ever have to travel between two cities in the worst case scenario. Your task is to help him find this distance while keeping the amount of web searches he has to make small. There is a hidden tree(^{\text{∗}}) with (n) vertices. You can make queries. In one query, you choose two vertices (1 \le u, v \le n) and an integer (0 \le d \le n); the grader responds with (1) if (\operatorname{dist}(u, v) \ge d) and (0) otherwise. Here, (\operatorname{dist}(u,v)) denotes the distance(^{\text{†}}) between vertices (u) and (v) in the tree. Your task is to determine the diameter's length(^{\text{‡}}) of the tree and any pair of nodes that are this distance apart. You may ask at most (3 \cdot n) queries. (^{\text{∗}})A tree is a connected graph without cycles. (^{\text{†}})The distance between two nodes in a tree is the number of edges in the unique simple path between these nodes. (^{\text{‡}})The diameter's length is the largest distance between two vertices. Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 500)). The description of the test cases follows. The first line of each test case contains (n) ((2 \le n \le 1000)), denoting the number of vertices in the tree. It is guaranteed that the sum of (n) over all test cases does not exceed (1000). To make a query, first pick (u), (v) and (d) ((1 \le u, v \le n), (0 \le d \le n)), a pair of nodes and a constant to check the distance between them against, and output the following line (without

Tutorials

Codeforces Round 1118 (Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
388868196 raaz7 C Aug. 30, 2026, 3:44 a.m. OK C++17 (GCC 7-32) TESTS 20 31 0
388864834 qwertyui66 C Aug. 30, 2026, 1:59 a.m. OK C++17 (GCC 7-32) TESTS 20 31 0
388862220 _raayyyaaaannnnn_ C Aug. 30, 2026, 12:05 a.m. OK C++17 (GCC 7-32) TESTS 20 31 0
388861782 hauserl C Aug. 29, 2026, 11:44 p.m. OK C++17 (GCC 7-32) TESTS 20 31 0
388850238 krishna17 C Aug. 29, 2026, 6:55 p.m. OK C++17 (GCC 7-32) TESTS 20 31 0
388843370 NikolaPD C Aug. 29, 2026, 6 p.m. OK C++17 (GCC 7-32) TESTS 20 31 0
388837857 the_69 C Aug. 29, 2026, 5:04 p.m. OK C++17 (GCC 7-32) TESTS 20 31 0
388834610 rohi156 C Aug. 29, 2026, 4:34 p.m. OK C++17 (GCC 7-32) TESTS 20 31 0
388832002 LinearJiggle1 C Aug. 29, 2026, 4:28 p.m. OK C++17 (GCC 7-32) TESTS 20 31 0
388828107 dobrevp C Aug. 29, 2026, 4:17 p.m. OK C++17 (GCC 7-32) TESTS 20 31 0
388870571 Kamming C Aug. 30, 2026, 4:38 a.m. OK C++20 (GCC 13-64) TESTS 20 31 0
388870207 yanglake_ C Aug. 30, 2026, 4:30 a.m. OK C++20 (GCC 13-64) TESTS 20 31 0
388844064 mdammar9891 C Aug. 29, 2026, 6:07 p.m. OK C++20 (GCC 13-64) TESTS 20 31 0
388839315 norikame C Aug. 29, 2026, 5:19 p.m. OK C++20 (GCC 13-64) TESTS 20 31 0
388835636 Nerfed_Ghost C Aug. 29, 2026, 4:46 p.m. OK C++20 (GCC 13-64) TESTS 20 31 0
388829697 saloni3494 C Aug. 29, 2026, 4:21 p.m. OK C++20 (GCC 13-64) TESTS 20 31 0
388826480 PPOOQQ C Aug. 29, 2026, 4:12 p.m. OK C++20 (GCC 13-64) TESTS 20 31 0
388826182 amcsz C Aug. 29, 2026, 4:11 p.m. OK C++20 (GCC 13-64) TESTS 20 31 0
388820325 k_san C Aug. 29, 2026, 3:54 p.m. OK C++20 (GCC 13-64) TESTS 20 31 0
388875547 AlexKo C Aug. 30, 2026, 6:07 a.m. OK C++20 (GCC 13-64) TESTS 20 31 102400
388873182 Primed C Aug. 30, 2026, 5:28 a.m. OK C++23 (GCC 14-64, msys2) TESTS 20 31 0
388868937 Dormon C Aug. 30, 2026, 4:02 a.m. OK C++23 (GCC 14-64, msys2) TESTS 20 31 0
388868796 ggbond567 C Aug. 30, 2026, 3:58 a.m. OK C++23 (GCC 14-64, msys2) TESTS 20 31 0
388868297 player21x C Aug. 30, 2026, 3:47 a.m. OK C++23 (GCC 14-64, msys2) TESTS 20 31 0
388862318 wanbitter C Aug. 30, 2026, 12:10 a.m. OK C++23 (GCC 14-64, msys2) TESTS 20 31 0
388860207 TheRZ C Aug. 29, 2026, 10:35 p.m. OK C++23 (GCC 14-64, msys2) TESTS 20 31 0
388858209 eggsort C Aug. 29, 2026, 9:30 p.m. OK C++23 (GCC 14-64, msys2) TESTS 20 31 0
388856182 Harsh_Verma14 C Aug. 29, 2026, 8:37 p.m. OK C++23 (GCC 14-64, msys2) TESTS 20 31 0
388856012 Harold C Aug. 29, 2026, 8:33 p.m. OK C++23 (GCC 14-64, msys2) TESTS 20 31 0
388855882 ikaurov C Aug. 29, 2026, 8:30 p.m. OK C++23 (GCC 14-64, msys2) TESTS 20 31 0
388839477 frag_ C Aug. 29, 2026, 5:20 p.m. OK GNU C11 TESTS 20 62 8396800
388836996 m_husssain C Aug. 29, 2026, 4:57 p.m. OK GNU C11 TESTS 20 62 8396800
388831371 EmberSeed_OFFICIAL C Aug. 29, 2026, 4:26 p.m. OK GNU C11 TESTS 20 62 8396800
388839413 petsernik C Aug. 29, 2026, 5:20 p.m. OK Go TESTS 20 62 2252800
388833245 hardiknarang2509 C Aug. 29, 2026, 4:31 p.m. OK Java 21 TESTS 20 203 921600
388861102 Aaryan99 C Aug. 29, 2026, 11:12 p.m. OK Java 21 TESTS 20 218 614400
388821854 Pavan__ C Aug. 29, 2026, 3:58 p.m. OK Java 21 TESTS 20 218 819200
388822853 _MShadow_ C Aug. 29, 2026, 4:01 p.m. OK Java 21 TESTS 20 218 921600
388833186 a5uwu C Aug. 29, 2026, 4:31 p.m. OK Java 21 TESTS 20 234 409600
388853948 Jiwesh86 C Aug. 29, 2026, 7:55 p.m. OK Java 21 TESTS 20 234 819200
388819185 aha C Aug. 29, 2026, 3:51 p.m. OK Java 21 TESTS 20 234 819200
388843237 vinayreddyalla6783 C Aug. 29, 2026, 5:58 p.m. OK Java 21 TESTS 20 234 1024000
388863825 ryukl C Aug. 30, 2026, 1:21 a.m. OK Java 21 TESTS 20 234 1126400
388823019 ansumanswain C Aug. 29, 2026, 4:02 p.m. OK Java 21 TESTS 20 234 1740800
388830633 Night1324 C Aug. 29, 2026, 4:24 p.m. OK Java 8 TESTS 20 171 0
388827979 CherryPick C Aug. 29, 2026, 4:16 p.m. OK Java 8 TESTS 20 171 0
388828878 R_A_Saha C Aug. 29, 2026, 4:19 p.m. OK PyPy 3 TESTS 20 187 3993600
388823220 rahul_annaldas1 C Aug. 29, 2026, 4:02 p.m. OK PyPy 3 TESTS 20 234 3276800
388843043 alexenkovova C Aug. 29, 2026, 5:56 p.m. OK PyPy 3-64 TESTS 20 109 2150400
388861554 towersfreak2006 C Aug. 29, 2026, 11:33 p.m. OK PyPy 3-64 TESTS 20 125 2150400
388833599 LeelakrishnaRajasimha C Aug. 29, 2026, 4:32 p.m. OK PyPy 3-64 TESTS 20 125 2150400
388826454 tranlehieu C Aug. 29, 2026, 4:12 p.m. OK PyPy 3-64 TESTS 20 125 2252800
388826190 KaveenKrithik C Aug. 29, 2026, 4:11 p.m. OK PyPy 3-64 TESTS 20 125 3584000
388826623 ImmatureGoat C Aug. 29, 2026, 4:12 p.m. OK PyPy 3-64 TESTS 20 140 1536000
388822941 Aethernis C Aug. 29, 2026, 4:02 p.m. OK PyPy 3-64 TESTS 20 140 1945600
388864225 _andrewliu_ C Aug. 30, 2026, 1:37 a.m. OK PyPy 3-64 TESTS 20 140 2150400
388825932 hassanzn04 C Aug. 29, 2026, 4:10 p.m. OK PyPy 3-64 TESTS 20 140 2150400
388836018 54skyxenon C Aug. 29, 2026, 4:48 p.m. OK PyPy 3-64 TESTS 20 140 2252800
388819636 Dp_Raghu C Aug. 29, 2026, 3:52 p.m. OK Python 3 TESTS 20 78 307200
388862397 RashNuke C Aug. 30, 2026, 12:13 a.m. OK Python 3 TESTS 20 93 204800
388833129 santanukumar C Aug. 29, 2026, 4:31 p.m. OK Python 3 TESTS 20 93 204800
388832490 _cicada_3301 C Aug. 29, 2026, 4:29 p.m. OK Python 3 TESTS 20 93 204800
388825837 DarkWeB10 C Aug. 29, 2026, 4:10 p.m. OK Python 3 TESTS 20 93 204800
388821234 amod_24 C Aug. 29, 2026, 3:56 p.m. OK Python 3 TESTS 20 93 204800
388856696 shouryasharan27 C Aug. 29, 2026, 8:48 p.m. OK Python 3 TESTS 20 93 409600
388828029 divyasingh22 C Aug. 29, 2026, 4:16 p.m. OK Python 3 TESTS 20 109 204800
388827162 SLoonker C Aug. 29, 2026, 4:14 p.m. OK Python 3 TESTS 20 109 204800
388825859 kathan1702 C Aug. 29, 2026, 4:10 p.m. OK Python 3 TESTS 20 109 204800
388860022 davidmiheev C Aug. 29, 2026, 10:28 p.m. OK Rust 2024 TESTS 20 46 0
388836885 darkkcyan C Aug. 29, 2026, 4:56 p.m. OK Rust 2024 TESTS 20 46 0
388829880 allcaps C Aug. 29, 2026, 4:22 p.m. OK Rust 2024 TESTS 20 46 0
388828395 cvs-650 C Aug. 29, 2026, 4:18 p.m. OK Rust 2024 TESTS 20 46 0

remove filters

Back to search problems