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 |
---|---|---|---|---|---|---|
1790 | Codeforces Round 847 (Div. 3) | FINISHED | False | 8100 | 62436263 | Jan. 27, 2023, 2:35 p.m. |
Solved$ |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
---|---|---|---|---|---|---|
( 3439 ) | F | Timofey and Black-White Tree | PROGRAMMING | brute force dfs and similar divide and conquer graphs greedy math shortest paths trees |
B"Timofey came to a famous summer school and found a tree on n vertices. A tree is a connected undirected graph without cycles. Every vertex of this tree, except c_0 , is colored white. The vertex c_0 is colored black. Timofey wants to color all the vertices of this tree in black. To do this, he performs n - 1 operations. During the i -th operation, he selects the vertex c_i , which is currently white, and paints it black. Let's call the positivity of tree the minimum distance between all pairs of different black vertices in it. The distance between the vertices v and u is the number of edges on the path from v to u . After each operation, Timofey wants to know the positivity of the current tree. The first line contains the integer t ( 1 <= t <= 10^4 ) -- the number of testcases. The first line of each testcase contains the integers n, c_0 ( 2 <= n <= 2 cdot 10^5 , 1 <= c_0 <= n ) -- the number of vertices in the tree and index of the initial black vertex. The second line of each testcase contains n - 1 unique integers c_1, c_2, ... , c_{n-1} ( 1 <= c_i <= n , c_i ne c_0 ), where c_i is the vertex which is colored black during the i -th operation. Each of the next n - 1 row of each testcase contains the integers v_i, u_i ( 1 <= v_i, u_i <= n ) -- edges in the tree. It is guaranteed that the sum of n for all testcases does not exceed 2 cdot 10^5 . For each testcase, print n - 1 integer on a separate line. The integer with index i must be equal to positivity of the tree obtained by the first i operations. In the first testcase, after the second operation, the tree looks like this: The distance between vertices 1 and 6 is 3 , the distance between vertices 4 and 6 is 3 , the distance between vertices 1 and 4 is 2 . The positivity of thi"... |
111948 |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
---|---|---|---|---|---|---|---|---|---|---|---|
190880497 | fzzsl | F | Jan. 27, 2023, 5:07 p.m. | OK | GNU C++14 | TESTS | 28 | 171 | 12800000 | ||
190913209 | 2022lishujia | F | Jan. 28, 2023, 12:40 a.m. | OK | GNU C++14 | TESTS | 28 | 187 | 27238400 | ||
190918214 | nguyennhat.110120 | F | Jan. 28, 2023, 2:52 a.m. | OK | GNU C++14 | TESTS | 28 | 202 | 17817600 | ||
190897658 | dimitri1244 | F | Jan. 27, 2023, 7:32 p.m. | OK | GNU C++14 | TESTS | 28 | 202 | 17817600 | ||
190902745 | alvinvaja | F | Jan. 27, 2023, 8:42 p.m. | OK | GNU C++14 | TESTS | 28 | 202 | 19968000 | ||
190924357 | Neko668 | F | Jan. 28, 2023, 4:43 a.m. | OK | GNU C++14 | TESTS | 28 | 202 | 24166400 | ||
190893233 | ayush_n | F | Jan. 27, 2023, 6:45 p.m. | OK | GNU C++14 | TESTS | 28 | 202 | 24166400 | ||
190897189 | dimitri1244 | F | Jan. 27, 2023, 7:27 p.m. | OK | GNU C++14 | TESTS | 28 | 217 | 17817600 | ||
190919463 | m0rtery | F | Jan. 28, 2023, 3:19 a.m. | OK | GNU C++14 | TESTS | 28 | 218 | 13004800 | ||
190898552 | 13_Riishiii_10 | F | Jan. 27, 2023, 7:43 p.m. | OK | GNU C++14 | TESTS | 28 | 218 | 33792000 |
Back to search problems