Codeforces Round 973 (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
2013 Codeforces Round 973 (Div. 2) FINISHED False 7200 49562723 Sept. 20, 2024, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 160 ) F2 Game in Tree (Hard Version) PROGRAMMING binary search data structures trees

This is the hard version of the problem. In this version, it is not guaranteed that (u = v). You can make hacks only if both versions of the problem are solved. Alice and Bob are playing a fun game on a tree. This game is played on a tree with (n) vertices, numbered from (1) to (n). Recall that a tree with (n) vertices is an undirected connected graph with (n - 1) edges. Alice and Bob take turns, with Alice going first. Each player starts at some vertex. On their turn, a player must move from the current vertex to a neighboring vertex that has not yet been visited by anyone. The first player who cannot make a move loses. You are given two vertices (u) and (v). Represent the simple path from vertex (u) to (v) as an array (p_1, p_2, p_3, \ldots, p_m), where (p_1 = u), (p_m = v), and there is an edge between (p_i) and (p_{i + 1}) for all (i) ((1 \le i < m)). You need to determine the winner of the game if Alice starts at vertex (1) and Bob starts at vertex (p_j) for each (j) (where (1 \le j \le m)). 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) ((2 \le n \le 2 \cdot 10^5)) — the number of vertices in the tree. Each of the following (n - 1) lines contains two integers (a) and (b) ((1 \le a, b \le n)), denoting an undirected edge between vertices (a) and (b). It is guaranteed that these edges form a tree. The last line of each test case contains two integers (u) and (v) ((2 \le u, v \le n)). It is guaranteed that the path from (u) to (v) does not pass through vertex (1). It is guaranteed that the sum of (n) over all test cases does not exceed (2 \cdot 10^5). For each test case, output (m) lines. In the (i)-th line, print the win

Tutorials

134298

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
282141958 LNian F2 Sept. 21, 2024, 1:27 a.m. OK C++20 (GCC 13-64) TESTS 51 452 103731200
282145989 your_submissions_ F2 Sept. 21, 2024, 2:36 a.m. OK C++20 (GCC 13-64) TESTS 51 546 92364800
282120215 BurnedChicken F2 Sept. 20, 2024, 7:13 p.m. OK C++20 (GCC 13-64) TESTS 51 593 44748800
282112828 kotatsugame F2 Sept. 20, 2024, 6:13 p.m. OK C++20 (GCC 13-64) TESTS 51 608 43929600
282111954 Ormlis F2 Sept. 20, 2024, 6:08 p.m. OK C++20 (GCC 13-64) TESTS 51 687 77107200
282155074 Dominater069 F2 Sept. 21, 2024, 4:43 a.m. OK C++20 (GCC 13-64) TESTS 51 983 130355200
282111565 Ormlis F2 Sept. 20, 2024, 6:05 p.m. OK C++20 (GCC 13-64) TESTS 51 2952 56012800
282162223 SparshMittal F2 Sept. 21, 2024, 6:04 a.m. OK C++23 (GCC 14-64, msys2) TESTS 51 437 107315200
282117608 _MASSIMO_ F2 Sept. 20, 2024, 6:51 p.m. OK C++23 (GCC 14-64, msys2) TESTS 51 530 91852800
282102718 arvindf232 F2 Sept. 20, 2024, 4:34 p.m. OK Kotlin 1.9 TESTS 51 577 77107200

remove filters

Back to search problems