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 |
|---|---|---|---|---|---|---|
| 2063 | Codeforces Round 1000 (Div. 2) | FINISHED | False | 7200 | 38858123 | Jan. 22, 2025, 12:05 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 2343 ) | E | Triangle Tree | PROGRAMMING | data structures dfs and similar dp dsu greedy trees |
You are given a rooted tree(^{\text{∗}}) containing (n) vertices rooted at vertex (1). A pair of vertices ((u,v)) is called a good pair if (u) is not an ancestor(^{\text{†}}) of (v) and (v) is not an ancestor of (u). For any two vertices, (\text{dist}(u,v)) is defined as the number of edges on the unique simple path from (u) to (v), and (\text{lca}(u,v)) is defined as their lowest common ancestor . A function (f(u,v)) is defined as follows. If ((u,v)) is a good pair, (f(u,v)) is the number of distinct integer values (x) such that there exists a non-degenerate triangle (^{\text{‡}}) formed by side lengths (\text{dist}(u,\text{lca}(u,v))), (\text{dist}(v,\text{lca}(u,v))), and (x). Otherwise, (f(u,v)) is (0). You need to find the following value: ()\sum_{i = 1}^{n-1} \sum_{j = i+1}^n f(i,j).() (^{\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{†}})An ancestor of vertex (v) is any vertex on the simple path from (v) to the root, including the root, but not including (v). The root has no ancestors. (^{\text{‡}})A triangle with side lengths (a), (b), (c) is non-degenerate when (a+b > c), (a+c > b), (b+c > a). 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 a single integer (n) ((1 \le n \le 3 \cdot 10^5)). Each of the next (n-1) lines contains two integers (u_i) and (v_i), denoting the two vertices connected by an edge ((1 \le u_i,v_i \le n), (u_i \neq v_i)). It is guaranteed that the given edges form a tree. It is guaranteed that the sum of (n) over all test cases does not exceed (3 \cdot 10^5). For each test case, output the answer on a |
| Codeforces Round 1000 (Div. 2) — Editorial |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 302531041 | JiangSY | E | Jan. 23, 2025, 1:21 a.m. | OK | C++17 (GCC 7-32) | TESTS | 42 | 234 | 18534400 | ||
| 302525955 | 2025caiminghui | E | Jan. 22, 2025, 11:43 p.m. | OK | C++17 (GCC 7-32) | TESTS | 42 | 234 | 32563200 | ||
| 302528674 | 1121Jiang | E | Jan. 23, 2025, 12:40 a.m. | OK | C++17 (GCC 7-32) | TESTS | 42 | 265 | 26009600 | ||
| 302535650 | 1121Jiang | E | Jan. 23, 2025, 2:36 a.m. | OK | C++17 (GCC 7-32) | TESTS | 42 | 281 | 26112000 | ||
| 302535629 | dayz_break404 | E | Jan. 23, 2025, 2:36 a.m. | OK | C++17 (GCC 7-32) | TESTS | 42 | 296 | 25907200 | ||
| 302515042 | Carits | E | Jan. 22, 2025, 8:11 p.m. | OK | C++17 (GCC 7-32) | TESTS | 42 | 296 | 39321600 | ||
| 302525014 | wuchenyu01 | E | Jan. 22, 2025, 11:17 p.m. | OK | C++17 (GCC 7-32) | TESTS | 42 | 311 | 34508800 | ||
| 302547221 | rnishu12 | E | Jan. 23, 2025, 5:11 a.m. | OK | C++17 (GCC 7-32) | TESTS | 42 | 312 | 19046400 | ||
| 302507941 | -adhd- | E | Jan. 22, 2025, 6:59 p.m. | OK | C++17 (GCC 7-32) | TESTS | 42 | 312 | 23756800 | ||
| 302539256 | Aftglw | E | Jan. 23, 2025, 3:26 a.m. | OK | C++17 (GCC 7-32) | TESTS | 42 | 327 | 34611200 | ||
| 302530080 | Locix | E | Jan. 23, 2025, 1:05 a.m. | OK | C++20 (GCC 13-64) | TESTS | 42 | 202 | 62566400 | ||
| 302538076 | BronzeMelon | E | Jan. 23, 2025, 3:11 a.m. | OK | C++20 (GCC 13-64) | TESTS | 42 | 249 | 40038400 | ||
| 302461076 | DCZISSB | E | Jan. 22, 2025, 2:04 p.m. | OK | C++20 (GCC 13-64) | TESTS | 42 | 249 | 47616000 | ||
| 302527283 | larryyu_cf | E | Jan. 23, 2025, 12:14 a.m. | OK | C++20 (GCC 13-64) | TESTS | 42 | 265 | 47308800 | ||
| 302537288 | daoqi | E | Jan. 23, 2025, 3 a.m. | OK | C++20 (GCC 13-64) | TESTS | 42 | 281 | 21094400 | ||
| 302518539 | Igorjan94 | E | Jan. 22, 2025, 9:01 p.m. | OK | C++20 (GCC 13-64) | TESTS | 42 | 281 | 32870400 | ||
| 302497287 | xqqddqqc | E | Jan. 22, 2025, 5:43 p.m. | OK | C++20 (GCC 13-64) | TESTS | 42 | 296 | 30720000 | ||
| 302497709 | xqqddqqc | E | Jan. 22, 2025, 5:46 p.m. | OK | C++20 (GCC 13-64) | TESTS | 42 | 296 | 31027200 | ||
| 302547816 | chenwenmo | E | Jan. 23, 2025, 5:17 a.m. | OK | C++20 (GCC 13-64) | TESTS | 42 | 296 | 31948800 | ||
| 302498622 | xqqddqqc | E | Jan. 22, 2025, 5:52 p.m. | OK | C++20 (GCC 13-64) | TESTS | 42 | 296 | 33792000 | ||
| 302530176 | yjf1225 | E | Jan. 23, 2025, 1:07 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 42 | 264 | 62566400 | ||
| 302468342 | rewhile | E | Jan. 22, 2025, 3 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 42 | 265 | 30310400 | ||
| 302475570 | Yonghu_3913 | E | Jan. 22, 2025, 3:34 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 42 | 280 | 70553600 | ||
| 302466677 | 415411 | E | Jan. 22, 2025, 2:54 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 42 | 281 | 68915200 | ||
| 302543253 | anewacmer | E | Jan. 23, 2025, 4:20 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 42 | 296 | 27033600 | ||
| 302526112 | klein199 | E | Jan. 22, 2025, 11:47 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 42 | 296 | 34816000 | ||
| 302542684 | binminh01 | E | Jan. 23, 2025, 4:11 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 42 | 311 | 29491200 | ||
| 302517507 | Dominater069 | E | Jan. 22, 2025, 8:45 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 42 | 311 | 38195200 | ||
| 302469493 | xuhaotian | E | Jan. 22, 2025, 3:05 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 42 | 311 | 42086400 | ||
| 302470513 | gxd | E | Jan. 22, 2025, 3:10 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 42 | 327 | 41779200 | ||
| 302526272 | rainboy | E | Jan. 22, 2025, 11:51 p.m. | OK | GNU C11 | TESTS | 42 | 249 | 26521600 | ||
| 302466536 | 0x3F | E | Jan. 22, 2025, 2:54 p.m. | OK | Go | TESTS | 42 | 437 | 89600000 | ||
| 302472799 | 0x3F | E | Jan. 22, 2025, 3:20 p.m. | OK | Go | TESTS | 42 | 452 | 89497600 | ||
| 302479536 | MarcAS | E | Jan. 22, 2025, 3:56 p.m. | OK | Java 8 | TESTS | 42 | 1577 | 186675200 | ||
| 302479493 | vilhelmthorsson | E | Jan. 22, 2025, 3:56 p.m. | OK | PyPy 3-64 | TESTS | 42 | 780 | 78950400 | ||
| 302489287 | x3mka | E | Jan. 22, 2025, 4:55 p.m. | OK | PyPy 3-64 | TESTS | 42 | 984 | 107724800 | ||
| 302524427 | suo_4r | E | Jan. 22, 2025, 11 p.m. | OK | PyPy 3-64 | TESTS | 42 | 1062 | 72294400 | ||
| 302460519 | OpalFarnsworth | E | Jan. 22, 2025, 2:03 p.m. | OK | Rust 2021 | TESTS | 42 | 296 | 67174400 | ||
| 302507401 | kalinov | E | Jan. 22, 2025, 6:54 p.m. | OK | Rust 2021 | TESTS | 42 | 296 | 76288000 | ||
| 302515967 | 123gjweq2 | E | Jan. 22, 2025, 8:23 p.m. | OK | Rust 2021 | TESTS | 42 | 343 | 75059200 | ||
| 302508152 | kalinov | E | Jan. 22, 2025, 7:01 p.m. | OK | Rust 2021 | TESTS | 42 | 358 | 84070400 |
Back to search problems