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.
Problems
B'You are given a tree with n vertices numbered 1, ldots, n . A tree is a connected simple graph without cycles. Let mathrm{dist}(u, v) be the number of edges in the unique simple path connecting vertices u and v . Let mathrm{diam}(l, r) = max mathrm{dist}(u, v) over all pairs u, v such that l <= q u, v <= q r . Compute sum_{1 <= q l <= q r <= q n} mathrm{diam}(l, r) . The first line contains a single integer n ( 1 <= q n <= q 10^5 ) -- the number of vertices in the tree. The next n - 1 lines describe the tree edges. Each of these lines contains two integers u, v ( 1 <= q u, v <= q n ) -- endpoint indices of the respective tree edge. It is guaranteed that the edge list indeed describes a tree. Print a single integer -- sum_{1 <= q l <= q r <= q n} mathrm{diam}(l, r) . '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
101784289 |
psycho437 |
F |
Dec. 19, 2020, 3:51 p.m. |
OK |
GNU C++11 |
TESTS |
21 |
1170 |
61030400 |
|
|
101801623 |
HIR180 |
F |
Dec. 19, 2020, 7:47 p.m. |
OK |
GNU C++11 |
TESTS |
21 |
2371 |
60825600 |
|
|
101800432 |
HIR180 |
F |
Dec. 19, 2020, 7:26 p.m. |
OK |
GNU C++11 |
TESTS |
21 |
6988 |
27955200 |
|
|
101769225 |
jijiang |
F |
Dec. 19, 2020, 12:23 p.m. |
OK |
GNU C++14 |
TESTS |
20 |
1091 |
61132800 |
|
|
101792382 |
sh1194 |
F |
Dec. 19, 2020, 5:27 p.m. |
OK |
GNU C++14 |
TESTS |
21 |
1107 |
61235200 |
|
|
101792021 |
sh1194 |
F |
Dec. 19, 2020, 5:23 p.m. |
OK |
GNU C++14 |
TESTS |
21 |
1123 |
61132800 |
|
|
101792250 |
sh1194 |
F |
Dec. 19, 2020, 5:26 p.m. |
OK |
GNU C++14 |
TESTS |
21 |
1263 |
61132800 |
|
|
101806861 |
Benq |
F |
Dec. 19, 2020, 9:50 p.m. |
OK |
GNU C++17 (64) |
TESTS |
21 |
1887 |
102604800 |
|
|
remove filters
Back to search problems