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 |
|---|---|---|---|---|---|---|
| 2126 | Codeforces Round 1037 (Div. 3) | FINISHED | False | 8100 | 23642723 | July 17, 2025, 2:35 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 4272 ) | F | 1-1-1, Free Tree! | PROGRAMMING | data structures dfs and similar graphs trees |
Given a tree(^{\text{∗}}) with (n) vertices numbered from (1) to (n). Each vertex has an initial color (a_i). Each edge of the tree is defined by three numbers: (u_i), (v_i), and (c_i), where (u_i) and (v_i) are the endpoints of the edge, and (c_i) is the edge parameter. The cost of the edge is defined as follows: if the colors of vertices (u_i) and (v_i) are the same, the cost is (0); otherwise, the cost is (c_i). You are also given (q) queries. Each query has the form: repaint vertex (v) to color (x). The queries depend on each other (after each query, the color change is preserved). After each query, you need to output the sum of the costs of all edges in the tree. (^{\text{∗}})A tree is a connected graph without cycles. The first line contains an integer (t) ((1 \le t \le 10^4)) — the number of test cases. The first line of each test case contains two integers (n) and (q) ((1 \le n, q \le 2\cdot10^5)) — the number of vertices and the number of queries, respectively. The second line contains (n) integers (a_1, a_2, \dots, a_n) ((1 \le a_i \le n)), where the (i)-th number specifies the initial color of vertex (i). The next (n-1) lines describe the edges of the tree. Each line contains three integers (u), (v), and (c), denoting an edge between vertices (u) and (v) with parameter (c) ((1 \le u, v \le n), (1 \le c \le 10^9)). The following (q) lines contain the queries. Each query contains two integers (v) and (x) — repaint vertex (v) to color (x) ((1 \le v,x \le n)). It is guaranteed that the sum of (n) and the sum of (q) across all test cases do not exceed (2\cdot10^5). For each query, output a single integer on a separate line — the sum of the costs of all edges in the tree after applying the corresponding query. First test: (n =1), one vertex — no edges. Query: rep |
| 144845 |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 329545723 | patraranya4 | F | July 17, 2025, 8:04 p.m. | OK | C++17 (GCC 7-32) | TESTS | 36 | 483 | 23142400 | ||
| 329550789 | Dhruthi_MS | F | July 17, 2025, 9:21 p.m. | OK | C++17 (GCC 7-32) | TESTS | 36 | 483 | 23347200 | ||
| 329526376 | The_Elephant | F | July 17, 2025, 5:15 p.m. | OK | C++17 (GCC 7-32) | TESTS | 36 | 499 | 20787200 | ||
| 329535817 | Soaked | F | July 17, 2025, 6:22 p.m. | OK | C++17 (GCC 7-32) | TESTS | 36 | 515 | 21196800 | ||
| 329537543 | hackdecode1920 | F | July 17, 2025, 6:37 p.m. | OK | C++17 (GCC 7-32) | TESTS | 36 | 515 | 21504000 | ||
| 329554694 | Anvesh1007 | F | July 17, 2025, 11:01 p.m. | OK | C++17 (GCC 7-32) | TESTS | 36 | 530 | 21504000 | ||
| 329572144 | PythonicVarun | F | July 18, 2025, 3:31 a.m. | OK | C++17 (GCC 7-32) | TESTS | 36 | 531 | 24678400 | ||
| 329528037 | algoman1ac | F | July 17, 2025, 5:25 p.m. | OK | C++17 (GCC 7-32) | TESTS | 36 | 546 | 24371200 | ||
| 329536810 | AtulJ1314 | F | July 17, 2025, 6:31 p.m. | OK | C++17 (GCC 7-32) | TESTS | 36 | 562 | 18022400 | ||
| 329533584 | Parth4444 | F | July 17, 2025, 6:04 p.m. | OK | C++17 (GCC 7-32) | TESTS | 36 | 577 | 22630400 | ||
| 329562348 | i_love_sqrt_decomp | F | July 18, 2025, 1:58 a.m. | OK | C++20 (GCC 13-64) | TESTS | 36 | 156 | 20377600 | ||
| 329579729 | lyt-715 | F | July 18, 2025, 5:04 a.m. | OK | C++20 (GCC 13-64) | TESTS | 36 | 406 | 48230400 | ||
| 329528711 | _Kee | F | July 17, 2025, 5:29 p.m. | OK | C++20 (GCC 13-64) | TESTS | 36 | 406 | 83558400 | ||
| 329533923 | Ladamalina | F | July 17, 2025, 6:06 p.m. | OK | C++20 (GCC 13-64) | TESTS | 36 | 437 | 57036800 | ||
| 329533895 | udiandianis | F | July 17, 2025, 6:06 p.m. | OK | C++20 (GCC 13-64) | TESTS | 36 | 452 | 40243200 | ||
| 329581564 | eric574 | F | July 18, 2025, 5:25 a.m. | OK | C++20 (GCC 13-64) | TESTS | 36 | 452 | 41574400 | ||
| 329530244 | Yaimsea | F | July 17, 2025, 5:40 p.m. | OK | C++20 (GCC 13-64) | TESTS | 36 | 452 | 186163200 | ||
| 329561718 | kutedddd | F | July 18, 2025, 1:49 a.m. | OK | C++20 (GCC 13-64) | TESTS | 36 | 468 | 39219200 | ||
| 329542230 | XtremeXSPC | F | July 17, 2025, 7:24 p.m. | OK | C++20 (GCC 13-64) | TESTS | 36 | 468 | 41574400 | ||
| 329531156 | chenliyuan | F | July 17, 2025, 5:46 p.m. | OK | C++20 (GCC 13-64) | TESTS | 36 | 499 | 60211200 | ||
| 329561837 | i_love_sqrt_decomp | F | July 18, 2025, 1:51 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 36 | 311 | 25600000 | ||
| 329561960 | i_love_sqrt_decomp | F | July 18, 2025, 1:53 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 36 | 343 | 24576000 | ||
| 329554485 | shiny_shine | F | July 17, 2025, 10:55 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 36 | 343 | 28672000 | ||
| 329561892 | i_love_sqrt_decomp | F | July 18, 2025, 1:52 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 36 | 343 | 29286400 | ||
| 329554527 | shiny_shine | F | July 17, 2025, 10:56 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 36 | 358 | 28672000 | ||
| 329554516 | shiny_shine | F | July 17, 2025, 10:56 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 36 | 374 | 28672000 | ||
| 329580323 | Arvi_saleque | F | July 18, 2025, 5:11 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 36 | 390 | 26828800 | ||
| 329581189 | aaaaAAAAAaaAabaaAAAAAaa | F | July 18, 2025, 5:20 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 36 | 390 | 46182400 | ||
| 329565466 | 424479543 | F | July 18, 2025, 2:30 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 36 | 436 | 26726400 | ||
| 329528188 | bOrax10 | F | July 17, 2025, 5:26 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 36 | 436 | 38195200 | ||
| 329525605 | pengin_2000 | F | July 17, 2025, 5:11 p.m. | OK | GNU C11 | TESTS | 36 | 1062 | 32153600 | ||
| 329539587 | nhirsama | F | July 17, 2025, 6:56 p.m. | OK | Go | TESTS | 36 | 749 | 123187200 | ||
| 329538202 | nhirsama | F | July 17, 2025, 6:43 p.m. | OK | Go | TESTS | 36 | 811 | 68198400 | ||
| 329572071 | kartik__sethi | F | July 18, 2025, 3:30 a.m. | OK | Java 21 | TESTS | 36 | 1609 | 162201600 | ||
| 329552638 | Gurvender | F | July 17, 2025, 10:05 p.m. | OK | Java 21 | TESTS | 36 | 3749 | 119193600 | ||
| 329538168 | kasiru_69 | F | July 17, 2025, 6:43 p.m. | OK | Java 8 | TESTS | 36 | 1905 | 169574400 | ||
| 329574366 | miztom | F | July 18, 2025, 3:57 a.m. | OK | PyPy 3-64 | TESTS | 36 | 1202 | 140185600 | ||
| 329550225 | denilb | F | July 17, 2025, 9:10 p.m. | OK | PyPy 3-64 | TESTS | 36 | 1233 | 114176000 | ||
| 329577205 | miztom | F | July 18, 2025, 4:35 a.m. | OK | PyPy 3-64 | TESTS | 36 | 1280 | 162304000 | ||
| 329550729 | grecil | F | July 17, 2025, 9:20 p.m. | OK | PyPy 3-64 | TESTS | 36 | 1280 | 182579200 | ||
| 329573223 | miztom | F | July 18, 2025, 3:43 a.m. | OK | PyPy 3-64 | TESTS | 36 | 1280 | 195891200 | ||
| 329577548 | miztom | F | July 18, 2025, 4:38 a.m. | OK | PyPy 3-64 | TESTS | 36 | 1312 | 162406400 | ||
| 329577376 | miztom | F | July 18, 2025, 4:37 a.m. | OK | PyPy 3-64 | TESTS | 36 | 1343 | 149196800 | ||
| 329566305 | miztom | F | July 18, 2025, 2:38 a.m. | OK | PyPy 3-64 | TESTS | 36 | 1358 | 195584000 | ||
| 329565681 | miztom | F | July 18, 2025, 2:32 a.m. | OK | PyPy 3-64 | TESTS | 36 | 1374 | 196198400 | ||
| 329565055 | miztom | F | July 18, 2025, 2:26 a.m. | OK | PyPy 3-64 | TESTS | 36 | 1405 | 195072000 | ||
| 329583261 | Sycamore_Ma | F | July 18, 2025, 5:43 a.m. | OK | Python 3 | TESTS | 36 | 2359 | 90112000 | ||
| 329553772 | JakeMate14 | F | July 17, 2025, 10:35 p.m. | OK | Rust 2021 | TESTS | 36 | 812 | 69427200 |
Back to search problems