Problem I

Statement
Copy Copied
Description:
After many unsuccessful tries, Mashtali decided to copy modify an AtCoder problem. So here is his copied new problem:

There is a tree with $$$n$$$ vertices and some non-empty set of the vertices are pinned to the ground.

Two players play a game against each other on the tree. They alternately perform the following action:

- Remove an edge from the tree, then remove every connected component that has no pinned vertex.The player who cannot move loses(every edge has been deleted already).

You are given the tree, but not the set of the pinned vertices. Your task is to determine, for each $$$k$$$, the winner of the game, if only the vertices $$$1, 2, 3, \ldots, k$$$ are pinned and both players play optimally.

Input Format:
The first line of input contains an integer $$$n$$$ — the number of vertices ($$$1 \le n \le 3 \cdot 10^5$$$).

The $$$i$$$-th of the following $$$n-1$$$ lines contains two integers $$$u_i, v_i$$$ ($$$1 \le u_i, v_i \le n$$$, $$$u_i \ne v_i$$$) — the endpoints of the $$$i$$$-th edge. It's guaranteed that these edges form a tree.

Output Format:
Print a string of length $$$n$$$. The $$$i$$$-th character should be '1' if the first player wins the $$$i$$$-th scenario, and '2' otherwise.

Note:
Below you can see the tree in the first sample :

If $$$k = 1$$$ then the first player can cut the edge $$$(1, 2)$$$.

If $$$k = 2$$$ or $$$k = 3$$$, the first player can cut the edge $$$(2, 4)$$$, after that only the edges $$$(1, 2)$$$ and $$$(2, 3)$$$ remain. After the second players move, there will be a single edge left for the first player to cut. So first player wins.

Submissions

IDLanguageExit CodeTimestampCodeStdoutStderrRetry
5941 go 0 2026-03-23T03:49:50.223593Z View View View Retry

Evaluations

Eval IDRun IDProviderModelLangSuccessTimestampPromptResponseStdoutStderrRetry
3592 20260322-230006 gemini gemini-3-pro-preview go false 2026-03-23T02:52:29.528406Z View View View View Retry