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 |
|---|---|---|---|---|---|---|
| 2127 | Atto Round 1 (Codeforces Round 1041, Div. 1 + Div. 2) | FINISHED | False | 10800 | 21828323 | Aug. 7, 2025, 2:35 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 2721 ) | E | Ancient Tree | PROGRAMMING | constructive algorithms data structures dfs and similar dsu greedy trees |
Bahamin came from the past to visit Ali — who came from the future. He also brought an ancient tree as a gift for Ali. He noticed some of its vertices have lost their color. Bahamin needs to repaint these vertices, but he is very busy with fixing his time machine. Fortunately (or unfortunately), dinosaurs now handle such tasks — for a fee, of course. He needs your help to find the coloring with minimum cost. So he gives you the problem as follows. You are given a rooted tree(^{\text{∗}}) of (n) vertices, where vertex (1) is the root. Each vertex has an integer weight (w_i) and a color (c_i), where the colors are integers between (1) and (k). However, some vertices have lost their colors, represented by (c_i = 0). We call vertex (v) cutie if there exists two vertices (x) and (y), such that (\operatorname{lca}(x, y))(^{\text{†}}) (= v), (c_x = c_y), and (c_x \neq c_v). The cost of the tree is the sum of weights of all cutie vertices. You have to assign colors between (1) and (k) to all the vertices which have lost their colors. Find the minimum possible cost among all valid colorings and provide a coloring with the minimum possible cost . (^{\text{∗}})A tree is a connected graph without cycles. A rooted tree is a tree where one vertex is special and called the root. (^{\text{†}})(\operatorname{lca}(x, y)) denotes the lowest common ancestor (LCA) of (x) and (y). 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) ((3 \leq n \leq 2 \cdot 10^5), (2 \leq k \leq n)) — the number of vertices and the number of colors. The second line contains (n) integers (w_1,w_2,\ldots,w_n) ((1 \leq w_i \leq 10^9)) — the weight of vertices. The third line contains (n) integers $$$ |
| Atto Round 1 (Codeforces Round 1041, Div. 1 + Div. 2) Editorial |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 332902013 | CrispyLobster | E | Aug. 7, 2025, 5:23 p.m. | OK | C++17 (GCC 7-32) | TESTS | 42 | 343 | 35328000 | ||
| 332944077 | Soyuen | E | Aug. 8, 2025, 2:52 a.m. | OK | C++17 (GCC 7-32) | TESTS | 42 | 374 | 45977600 | ||
| 332944170 | Soyuen | E | Aug. 8, 2025, 2:53 a.m. | OK | C++17 (GCC 7-32) | TESTS | 42 | 389 | 27545600 | ||
| 332957601 | TrendBattles | E | Aug. 8, 2025, 5:39 a.m. | OK | C++17 (GCC 7-32) | TESTS | 42 | 405 | 25292800 | ||
| 332899391 | ywjylx | E | Aug. 7, 2025, 5:16 p.m. | OK | C++17 (GCC 7-32) | TESTS | 42 | 421 | 34201600 | ||
| 332928466 | Born_To_Laugh | E | Aug. 7, 2025, 9:19 p.m. | OK | C++17 (GCC 7-32) | TESTS | 42 | 452 | 16588800 | ||
| 332945128 | XG0000 | E | Aug. 8, 2025, 3:05 a.m. | OK | C++17 (GCC 7-32) | TESTS | 42 | 452 | 18636800 | ||
| 332944606 | Elaina | E | Aug. 8, 2025, 2:58 a.m. | OK | C++17 (GCC 7-32) | TESTS | 42 | 468 | 18944000 | ||
| 332924452 | aprohACk | E | Aug. 7, 2025, 8:14 p.m. | OK | C++17 (GCC 7-32) | TESTS | 42 | 468 | 26521600 | ||
| 332901511 | csp1025 | E | Aug. 7, 2025, 5:22 p.m. | OK | C++17 (GCC 7-32) | TESTS | 42 | 468 | 71372800 | ||
| 332935010 | LOL_I_AM_SERZH | E | Aug. 8, 2025, 12:26 a.m. | OK | C++20 (GCC 13-64) | TESTS | 42 | 405 | 31539200 | ||
| 332928550 | SATSKY_2025target_LGM | E | Aug. 7, 2025, 9:21 p.m. | OK | C++20 (GCC 13-64) | TESTS | 42 | 421 | 27238400 | ||
| 332927106 | mmdrza | E | Aug. 7, 2025, 8:54 p.m. | OK | C++20 (GCC 13-64) | TESTS | 42 | 452 | 39424000 | ||
| 332906413 | fuad720 | E | Aug. 7, 2025, 5:33 p.m. | OK | C++20 (GCC 13-64) | TESTS | 42 | 468 | 35328000 | ||
| 332900881 | ckling | E | Aug. 7, 2025, 5:20 p.m. | OK | C++20 (GCC 13-64) | TESTS | 42 | 468 | 35942400 | ||
| 332957188 | 18o3 | E | Aug. 8, 2025, 5:35 a.m. | OK | C++20 (GCC 13-64) | TESTS | 42 | 468 | 64716800 | ||
| 332930750 | opPO | E | Aug. 7, 2025, 10:16 p.m. | OK | C++20 (GCC 13-64) | TESTS | 42 | 483 | 46899200 | ||
| 332913209 | Void_Wu | E | Aug. 7, 2025, 6:30 p.m. | OK | C++20 (GCC 13-64) | TESTS | 42 | 483 | 53145600 | ||
| 332900307 | qixinghui | E | Aug. 7, 2025, 5:19 p.m. | OK | C++20 (GCC 13-64) | TESTS | 42 | 484 | 66764800 | ||
| 332902222 | CYYsOPaccount | E | Aug. 7, 2025, 5:24 p.m. | OK | C++20 (GCC 13-64) | TESTS | 42 | 499 | 32972800 | ||
| 332940455 | 424479543 | E | Aug. 8, 2025, 2:03 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 42 | 328 | 39219200 | ||
| 332954430 | prairie2022 | E | Aug. 8, 2025, 5:03 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 42 | 374 | 32768000 | ||
| 332915419 | False0099 | E | Aug. 7, 2025, 6:44 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 42 | 421 | 40857600 | ||
| 332904314 | EternalHeart1314 | E | Aug. 7, 2025, 5:29 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 42 | 421 | 59699200 | ||
| 332899054 | Brilliance_2 | E | Aug. 7, 2025, 5:16 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 42 | 436 | 38297600 | ||
| 332903602 | milind0110 | E | Aug. 7, 2025, 5:27 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 42 | 437 | 37683200 | ||
| 332945986 | UFEQ | E | Aug. 8, 2025, 3:16 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 42 | 452 | 36147200 | ||
| 332899013 | kongcheng_lige | E | Aug. 7, 2025, 5:15 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 42 | 452 | 41267200 | ||
| 332917787 | daviedu | E | Aug. 7, 2025, 7:03 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 42 | 453 | 28979200 | ||
| 332903104 | Div2B2Hard | E | Aug. 7, 2025, 5:26 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 42 | 467 | 58880000 | ||
| 332923739 | rainboy | E | Aug. 7, 2025, 8:05 p.m. | OK | GNU C11 | TESTS | 42 | 1234 | 20480000 | ||
| 332921581 | Dominion948 | E | Aug. 7, 2025, 7:40 p.m. | OK | Go | TESTS | 42 | 514 | 78233600 | ||
| 332905584 | huixiong | E | Aug. 7, 2025, 5:32 p.m. | OK | Java 21 | TESTS | 42 | 1187 | 119091200 | ||
| 332931193 | Quasicoherent | E | Aug. 7, 2025, 10:30 p.m. | OK | Java 21 | TESTS | 42 | 1624 | 117145600 | ||
| 332957172 | yejordan8888 | E | Aug. 8, 2025, 5:35 a.m. | OK | PyPy 3-64 | TESTS | 42 | 999 | 148377600 | ||
| 332899831 | chinerist | E | Aug. 7, 2025, 5:18 p.m. | OK | PyPy 3-64 | TESTS | 42 | 1108 | 115814400 | ||
| 332943086 | twosquares | E | Aug. 8, 2025, 2:39 a.m. | OK | PyPy 3-64 | TESTS | 42 | 1515 | 103321600 | ||
| 332924229 | stan23456 | E | Aug. 7, 2025, 8:11 p.m. | OK | PyPy 3-64 | TESTS | 42 | 1593 | 164044800 | ||
| 332898760 | detteiuu | E | Aug. 7, 2025, 5:15 p.m. | OK | PyPy 3-64 | TESTS | 42 | 1671 | 144588800 | ||
| 332907346 | Ming_Xu | E | Aug. 7, 2025, 5:34 p.m. | OK | Rust 2021 | TESTS | 42 | 452 | 117452800 |
Back to search problems