Codeforces Global Round 17
I
Mashtali vs AtCoder
Codeforces
3100
原题
← H→
翻译中…

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

翻译中…

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

翻译中…

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 :

翻译中…

image

翻译中…

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.

翻译中…

样例

Input #1
5
1 2
2 3
2 4
4 5
Output #1
11122
InputCopy OutputCopy
Input #2
5
1 2
2 3
1 4
4 5
Output #2
21122
InputCopy OutputCopy
Input #3
6
1 2
2 4
5 1
6 3
3 2
Output #3
111111
InputCopy OutputCopy
Input #4
7
1 2
3 7
4 6
2 3
2 4
1 5
Output #4
2212222
InputCopy OutputCopy
题目信息
题号
1610I
时间限制
1 s
内存限制
256 MB
标签
博弈论
树

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。