Ethflow Round 1 (Codeforces Round 1001, Div. 1 + 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
2062 Ethflow Round 1 (Codeforces Round 1001, Div. 1 + Div. 2) FINISHED False 9000 38503523 Jan. 26, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 4313 ) E1 The Game (Easy Version) PROGRAMMING dfs and similar games graphs trees

This is the easy version of the problem. The difference between the versions is that in this version, you only need to find one of the possible nodes Cirno may choose. You can hack only if you solved all versions of this problem. Cirno and Daiyousei are playing a game with a tree(^{\text{∗}}) of (n) nodes, rooted at node (1). The value of the (i)-th node is (w_i). They take turns to play the game; Cirno goes first. In each turn, assuming the opponent chooses (j) in the last turn, the player can choose any remaining node (i) satisfying (w_i>w_j) and delete the subtree(^{\text{†}}) of node (i). In particular, Cirno can choose any node and delete its subtree in the first turn. The first player who can not operate wins , and they all hope to win. Find one of the possible nodes Cirno may choose so that she wins if both of them play optimally. (^{\text{∗}})A tree is a connected graph without cycles. (^{\text{†}})Node (u) is considered in the subtree of node (i) if any path from (1) to (u) must go through (i). The first line of input contains a single integer (t) ((1 \leq t \leq 10^5)) — the number of input test cases. The first line of each test case contains one integer (n) ((1 \le n \le 4\cdot 10^5)) — the number of nodes in the tree. The second line contains (n) integers (w_1,w_2,\ldots,w_n) ((1 \le w_i \le n)) — the value of each node. The next (n-1) lines contain the edges of the tree. The (i)-th line contains two integers (u_i,v_i) ((1\le u_i,v_i \le n), (u_i \neq v_i)) — an edge connecting (u_i) and (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 (4\cdot 10^5). For each test case, print one line. If Cirno wins the game, print any possible node she may choose in the first turn. Otherwise, print " 0 " (without quotes). In the first test case: If

Tutorials

Ethflow Round 1 (Codeforces Round 1001, Div. 1 + Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
303138905 KumaTachiRen E1 Jan. 26, 2025, 6:18 p.m. OK C# 10 TESTS 42 671 87859200
303130619 _Adel_Mahmoud_ E1 Jan. 26, 2025, 5:01 p.m. OK C# 10 TESTS 42 1578 137113600
303150579 _Equinox E1 Jan. 26, 2025, 8:04 p.m. OK C# 10 TESTS 42 2124 90214400

remove filters

Back to search problems