Codeforces Round 813 (Div. 2)

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
1712 Codeforces Round 813 (Div. 2) FINISHED False 8100 76778663 Aug. 13, 2022, 2:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 340 ) F Triameter PROGRAMMING data structures dfs and similar trees

B'A tree is a connected undirected graph without cycles. A weighted tree has a weight assigned to each edge. The degree of a vertex is the number of edges connected to this vertex. You are given a weighted tree with n vertices, each edge has a weight of 1 . Let L be the set of vertices with degree equal to 1 . You have to answer q independent queries. In the i -th query: The diameter of a graph is equal to max limits_{1 <= u < v <= n}{ operatorname{d}(u, v)} , where operatorname{d}(u, v) is the length of the shortest path between vertex u and vertex v . The first line contains a single integer n ( 3 <= n <= 10^6 ). The second line contains n - 1 integers p_2,p_3, ldots,p_n ( 1 <= p_i < i ) indicating that there is an edge between vertices i and p_i . It is guaranteed that the given edges form a tree. The third line contains a single integer q ( 1 <= q <= 10 ). The fourth line contains q integers x_1,x_2, ldots,x_q ( 1 <= x_i <= n ). All x_i are distinct. Print q integers in a single line -- the answers to the queries. The graph in the first test after adding the edges: '...

Tutorials

Codeforces Round #813 (Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
168198246 Wangxueyi F Aug. 13, 2022, 7:57 p.m. OK GNU C++14 TESTS 69 1450 312729600
168219993 Imot F Aug. 14, 2022, 3:38 a.m. OK GNU C++14 TESTS 69 3603 230912000
168215562 DerekFeng F Aug. 14, 2022, 2:07 a.m. OK GNU C++17 TESTS 69 1107 148377600
168217844 T_yunhui F Aug. 14, 2022, 2:56 a.m. OK GNU C++17 TESTS 69 1231 79872000
168220826 sum F Aug. 14, 2022, 3:53 a.m. OK GNU C++17 TESTS 69 1544 220467200
168187169 Lightnessqwq F Aug. 13, 2022, 6:10 p.m. OK GNU C++17 TESTS 69 1762 304844800
168192957 abchoudhary13 F Aug. 13, 2022, 6:59 p.m. OK GNU C++17 TESTS 69 2308 177664000
168210288 peti1234 F Aug. 13, 2022, 11:48 p.m. OK GNU C++17 TESTS 69 2589 212889600
168210253 peti1234 F Aug. 13, 2022, 11:47 p.m. OK GNU C++17 TESTS 69 2620 212889600
168209300 patou F Aug. 13, 2022, 11:22 p.m. OK GNU C++17 TESTS 69 3041 64921600
168212155 xiaoziyao F Aug. 14, 2022, 12:47 a.m. OK GNU C++17 (64) TESTS 69 2167 364748800
168187424 huangxiaohua F Aug. 13, 2022, 6:12 p.m. OK GNU C++17 (64) TESTS 69 2354 269619200
168187519 huangxiaohua F Aug. 13, 2022, 6:13 p.m. OK GNU C++17 (64) TESTS 69 2355 269619200
168227395 Alice114514 F Aug. 14, 2022, 5:44 a.m. OK GNU C++20 (64) TESTS 69 873 308531200
168199895 kfqg F Aug. 13, 2022, 8:18 p.m. OK GNU C++20 (64) TESTS 69 1013 106598400
168219225 Larry0101 F Aug. 14, 2022, 3:24 a.m. OK GNU C++20 (64) TESTS 69 2792 317132800
168185997 iztrax F Aug. 13, 2022, 6:01 p.m. OK GNU C++20 (64) TESTS 69 3946 402739200
168226830 JoesSR_ F Aug. 14, 2022, 5:36 a.m. OK GNU C++20 (64) TESTS 69 4367 604876800

remove filters

Back to search problems