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 |
|---|---|---|---|---|---|---|
| 2108 | Codeforces Round 1022 (Div. 2) | FINISHED | False | 7200 | 30295523 | May 1, 2025, 2:35 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 875 ) | E | Spruce Dispute | PROGRAMMING | constructive algorithms dfs and similar graphs implementation shortest paths trees |
It's already a hot April outside, and Polycarp decided that this is the perfect time to finally take down the spruce tree he set up several years ago. As he spent several hours walking around it, gathering his strength, he noticed something curious: the spruce is actually a tree(^{\text{∗}}) — and not just any tree, but one consisting of an odd number of vertices (n). Moreover, on (n-1) of the vertices hang Christmas ornaments, painted in exactly (\frac{n-1}{2}) distinct colors, with exactly two ornaments painted in each color. The remaining vertex, as tradition dictates, holds the tree's topper. At last, after several days of mental preparation, Polycarp began dismantling the spruce. First, he removed the topper and had already started taking apart some branches when suddenly a natural question struck him: how can he remove one of the tree's edges and rearrange the ornaments in such a way that the sum of the lengths of the simple paths between ornaments of the same color is as large as possible? In this problem, removing an edge from the tree is defined as follows: choose a pair of adjacent vertices (a) and (b) ((a < b)), then remove vertex (b) from the tree and reattach all of (b)'s adjacent vertices (except for (a)) directly to (a). Polycarp cannot continue dismantling his spruce until he gets an answer to this question. However, checking all possible options would take him several more years. Knowing your experience in competitive programming, he turned to you for help. But can you solve this dispute? (^{\text{∗}})A tree is a connected graph without cycles. 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 an odd number (n) ((3 \le n < 2 \cdot 10^5)) — the number of vertices in the tree. The following (n-1) lines describe the tree, given |
| Codeforces Round 1022 Editorial |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 318036695 | -adhd- | E | May 1, 2025, 7:47 p.m. | OK | C++17 (GCC 7-32) | TESTS | 24 | 342 | 18739200 | ||
| 318031911 | TheSahib | E | May 1, 2025, 6:50 p.m. | OK | C++17 (GCC 7-32) | TESTS | 24 | 343 | 25292800 | ||
| 318060650 | hxano | E | May 2, 2025, 4:16 a.m. | OK | C++17 (GCC 7-32) | TESTS | 24 | 343 | 25907200 | ||
| 318036890 | AlefHeKaaf | E | May 1, 2025, 7:49 p.m. | OK | C++17 (GCC 7-32) | TESTS | 24 | 358 | 33075200 | ||
| 318022864 | Darko1 | E | May 1, 2025, 5:32 p.m. | OK | C++17 (GCC 7-32) | TESTS | 24 | 390 | 22425600 | ||
| 318011744 | LOL_I_AM_SERZH | E | May 1, 2025, 4:28 p.m. | OK | C++17 (GCC 7-32) | TESTS | 24 | 405 | 16179200 | ||
| 318021907 | Riblji_Keksic | E | May 1, 2025, 5:26 p.m. | OK | C++17 (GCC 7-32) | TESTS | 24 | 405 | 18841600 | ||
| 318018845 | cyx | E | May 1, 2025, 5:08 p.m. | OK | C++17 (GCC 7-32) | TESTS | 24 | 405 | 45875200 | ||
| 318061685 | Teddydudu | E | May 2, 2025, 4:34 a.m. | OK | C++17 (GCC 7-32) | TESTS | 24 | 421 | 34406400 | ||
| 318021376 | Xerxes | E | May 1, 2025, 5:22 p.m. | OK | C++17 (GCC 7-32) | TESTS | 24 | 436 | 18432000 | ||
| 318014876 | noya2 | E | May 1, 2025, 4:33 p.m. | OK | C++20 (GCC 13-64) | TESTS | 24 | 187 | 3276800 | ||
| 318059635 | muxingchengfeng | E | May 2, 2025, 3:59 a.m. | OK | C++20 (GCC 13-64) | TESTS | 24 | 265 | 24883200 | ||
| 318042780 | kaiboy | E | May 1, 2025, 9:23 p.m. | OK | C++20 (GCC 13-64) | TESTS | 24 | 281 | 22835200 | ||
| 318060892 | cwz2024 | E | May 2, 2025, 4:21 a.m. | OK | C++20 (GCC 13-64) | TESTS | 24 | 296 | 16691200 | ||
| 318059710 | muxingchengfeng | E | May 2, 2025, 4 a.m. | OK | C++20 (GCC 13-64) | TESTS | 24 | 296 | 24883200 | ||
| 318042458 | Nxxlt | E | May 1, 2025, 9:16 p.m. | OK | C++20 (GCC 13-64) | TESTS | 24 | 311 | 35123200 | ||
| 318022909 | Khalid_Kamal_ | E | May 1, 2025, 5:32 p.m. | OK | C++20 (GCC 13-64) | TESTS | 24 | 311 | 40448000 | ||
| 318044788 | ahsoltan | E | May 1, 2025, 10:03 p.m. | OK | C++20 (GCC 13-64) | TESTS | 24 | 312 | 28672000 | ||
| 318059528 | muxingchengfeng | E | May 2, 2025, 3:58 a.m. | OK | C++20 (GCC 13-64) | TESTS | 24 | 327 | 24883200 | ||
| 318021538 | YoungLau | E | May 1, 2025, 5:24 p.m. | OK | C++20 (GCC 13-64) | TESTS | 24 | 328 | 28160000 | ||
| 318048530 | countless | E | May 1, 2025, 11:49 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 24 | 249 | 23244800 | ||
| 318048861 | cooluo | E | May 1, 2025, 11:58 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 24 | 249 | 32563200 | ||
| 318019316 | Legendary_Noxus | E | May 1, 2025, 5:11 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 24 | 265 | 60108800 | ||
| 318043137 | _Seele_Vollerei_ | E | May 1, 2025, 9:29 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 24 | 281 | 21196800 | ||
| 318065210 | Muschuang123 | E | May 2, 2025, 5:25 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 24 | 281 | 26112000 | ||
| 318061026 | WjhisTyAhzh | E | May 2, 2025, 4:22 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 24 | 296 | 21196800 | ||
| 318018687 | KobicGend | E | May 1, 2025, 5:08 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 24 | 296 | 23859200 | ||
| 318032114 | brun0matheus | E | May 1, 2025, 6:52 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 24 | 296 | 30412800 | ||
| 318040494 | Auchenai01 | E | May 1, 2025, 8:42 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 24 | 296 | 41881600 | ||
| 318046552 | catgirl | E | May 1, 2025, 10:48 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 24 | 296 | 48435200 | ||
| 318061542 | Ming_Xu | E | May 2, 2025, 4:31 a.m. | OK | Rust 2021 | TESTS | 24 | 265 | 53350400 | ||
| 318058404 | Ming_Xu | E | May 2, 2025, 3:38 a.m. | OK | Rust 2021 | TESTS | 24 | 280 | 53350400 | ||
| 318061720 | Ming_Xu | E | May 2, 2025, 4:35 a.m. | OK | Rust 2021 | TESTS | 24 | 296 | 53350400 | ||
| 318017597 | Ming_Xu | E | May 1, 2025, 5:02 p.m. | OK | Rust 2021 | TESTS | 24 | 343 | 54169600 | ||
| 318061097 | Ming_Xu | E | May 2, 2025, 4:24 a.m. | OK | Rust 2021 | TESTS | 24 | 374 | 53350400 |
Back to search problems