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 |
|---|---|---|---|---|---|---|
| 2155 | Codeforces Round 1056 (Div. 2) | FINISHED | False | 7200 | 16723523 | Oct. 5, 2025, 4:35 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 625 ) | F | Juan's Colorful Tree | PROGRAMMING | data structures data structures dfs and similar dfs and similar dsu graphs graphs trees |
Juan has a beautiful tree with (n) nodes numbered from (1) to (n). There are also (k) distinct colors numbered from (1) to (k). Each node (u) in the tree has its own set (C_u) which contains colors. Let's denote with (s) the quantity (\sum_{i=1}^n \left| C_i \right|). There are (q) queries where you will be given nodes (u) and (v). Let (P) denote the set of all nodes in the simple path between (u) and (v), inclusive. You are asked to calculate for each query the following quantity: ()\left| \bigcap_{w \in P} C_w \right|() That is, the cardinality of the intersection of the sets of all the nodes in the path from (u) to (v). In other words, calculate how many colors appear in every set on the path from (u) to (v). 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 four integers (n), (k), (s), and (q) ((1 \le n, k, q \le 3 \cdot 10^5, 1 \le s \le \min (nk, 3 \cdot 10^5))) — the number of nodes in the tree, the number of distinct colors, the sum of the cardinalities of all sets of colors, and the number of queries, respectively. The next (n-1) lines each contain two integers (u), (v) ((1 \le u, v \le n)), indicating that there's an edge between nodes (u) and (v). The next (s) lines each contain two integers (v) and (x) ((1 \le v \le n, 1 \le x \le k)) indicating that color (x) is in (C_v). All (s) lines are pairwise distinct. The next (q) lines each contain two integers (u) and (v) ((1 \le u, v \le n)), indicating a query between nodes (u) and (v). It is guaranteed that the sum of (n) over all test cases does not exceed (3 \cdot 10^5). It is guaranteed that the sum of (k) over all test cases does not exceed $$$3 \ |
| Codeforces Round 1056 (Div. 2) Editorial |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 342145137 | stone_heart | F | Oct. 6, 2025, 2:18 a.m. | OK | C++17 (GCC 7-32) | TESTS | 47 | 1577 | 81817600 | ||
| 342132753 | stone_heart | F | Oct. 5, 2025, 9:40 p.m. | OK | C++17 (GCC 7-32) | TESTS | 44 | 1592 | 81203200 | ||
| 342131724 | LastMagician | F | Oct. 5, 2025, 9:23 p.m. | OK | C++17 (GCC 7-32) | TESTS | 44 | 1733 | 45158400 | ||
| 342126556 | Az3ar | F | Oct. 5, 2025, 8:24 p.m. | OK | C++17 (GCC 7-32) | TESTS | 44 | 2061 | 82329600 | ||
| 342112450 | lotusblume | F | Oct. 5, 2025, 6:27 p.m. | OK | C++17 (GCC 7-32) | TESTS | 43 | 2702 | 81305600 | ||
| 342152461 | thecodingraceteam | F | Oct. 6, 2025, 3:58 a.m. | OK | C++20 (GCC 13-64) | TESTS | 47 | 530 | 45158400 | ||
| 342153874 | adam.jq.xu | F | Oct. 6, 2025, 4:16 a.m. | OK | C++20 (GCC 13-64) | TESTS | 47 | 905 | 107315200 | ||
| 342131658 | conqueror_of_tourist | F | Oct. 5, 2025, 9:22 p.m. | OK | C++20 (GCC 13-64) | TESTS | 44 | 937 | 124006400 | ||
| 342115298 | newbie_24 | F | Oct. 5, 2025, 6:32 p.m. | OK | C++20 (GCC 13-64) | TESTS | 43 | 952 | 98406400 | ||
| 342111964 | Fysty | F | Oct. 5, 2025, 6:26 p.m. | OK | C++20 (GCC 13-64) | TESTS | 43 | 983 | 64409600 | ||
| 342123693 | 111445 | F | Oct. 5, 2025, 8:02 p.m. | OK | C++20 (GCC 13-64) | TESTS | 43 | 999 | 81715200 | ||
| 342127364 | StupidGuy13 | F | Oct. 5, 2025, 8:31 p.m. | OK | C++20 (GCC 13-64) | TESTS | 44 | 1077 | 804044800 | ||
| 342131458 | conqueror_of_tourist | F | Oct. 5, 2025, 9:18 p.m. | OK | C++20 (GCC 13-64) | TESTS | 44 | 1078 | 235110400 | ||
| 342129598 | Abook | F | Oct. 5, 2025, 8:53 p.m. | OK | C++20 (GCC 13-64) | TESTS | 44 | 1156 | 56934400 | ||
| 342127010 | StupidGuy13 | F | Oct. 5, 2025, 8:28 p.m. | OK | C++20 (GCC 13-64) | TESTS | 44 | 1171 | 743424000 | ||
| 342106840 | maspy | F | Oct. 5, 2025, 6:16 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 43 | 671 | 98816000 | ||
| 342138551 | tin.le2 | F | Oct. 6, 2025, 12:15 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 47 | 671 | 127897600 | ||
| 342138416 | tin.le2 | F | Oct. 6, 2025, 12:11 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 47 | 749 | 127897600 | ||
| 342128892 | wh01sShakin | F | Oct. 5, 2025, 8:46 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 44 | 765 | 50688000 | ||
| 342159280 | krit3379 | F | Oct. 6, 2025, 5:21 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 47 | 827 | 56217600 | ||
| 342112114 | frosty11 | F | Oct. 5, 2025, 6:26 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 43 | 827 | 132096000 | ||
| 342126334 | SSerxhs | F | Oct. 5, 2025, 8:22 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 44 | 843 | 159744000 | ||
| 342128118 | wery0 | F | Oct. 5, 2025, 8:38 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 44 | 859 | 32972800 | ||
| 342128691 | coderg300711 | F | Oct. 5, 2025, 8:44 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 44 | 859 | 80281600 | ||
| 342145544 | ttamx | F | Oct. 6, 2025, 2:25 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 47 | 874 | 77619200 | ||
| 342138248 | arvindf232 | F | Oct. 6, 2025, 12:06 a.m. | OK | Kotlin 2.2 | TESTS | 47 | 1687 | 205824000 | ||
| 342139296 | arvindf232 | F | Oct. 6, 2025, 12:33 a.m. | OK | Kotlin 2.2 | TESTS | 47 | 1780 | 187596800 | ||
| 342139212 | arvindf232 | F | Oct. 6, 2025, 12:31 a.m. | OK | Kotlin 2.2 | TESTS | 47 | 1859 | 187596800 | ||
| 342137608 | arvindf232 | F | Oct. 5, 2025, 11:43 p.m. | OK | Kotlin 2.2 | TESTS | 47 | 2687 | 207462400 | ||
| 342137604 | arvindf232 | F | Oct. 5, 2025, 11:43 p.m. | OK | Kotlin 2.2 | TESTS | 47 | 2921 | 207155200 | ||
| 342117114 | Sugar_fan | F | Oct. 5, 2025, 6:34 p.m. | OK | Rust 2024 | TESTS | 43 | 2734 | 213913600 |
Back to search problems