#ABC126D. Even Relation

Even Relation

题目描述

We have a tree with NN vertices numbered 11 to NN. The ii-th edge in the tree connects Vertex uiu_i and Vertex viv_i, and its length is wiw_i. Your objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied:

  • For any two vertices painted in the same color, the distance between them is an even number.

Find a coloring of the vertices that satisfies the condition and print it. It can be proved that at least one such coloring exists under the constraints of this problem.

我们有一棵树,树上有 NN 个顶点,编号从 11NN 。树中的 ii 条边连接顶点 uiu_i 和顶点 viv_i ,其长度为 wiw_i 。您的目标是将树中的每个顶点涂成白色或黑色(将所有顶点涂成相同颜色也可以),从而满足以下条件:

  • 对于任何两个涂成相同颜色的顶点,它们之间的距离都是偶数。

找出满足条件的顶点颜色并打印出来。可以证明,在此问题的限制条件下,至少存在一个这样的着色。

输入格式

输入内容按以下格式标准输入:

NN
u1u_1 v1v_1 w1w_1
u2u_2 v2v_2 w2w_2
..
..
..
uN1u_{N - 1} vN1v_{N - 1} wN1w_{N - 1}

输出格式

NN 行打印满足条件的顶点着色。如果顶点 ii 被涂成白色,则 ii 行应包含 "0";如果顶点 ii 被涂成黑色,则 ii 行应包含 "1"。

如果有多种颜色满足条件,那么任何一种颜色都会被接受。

样例 #1

样例输入 #1

3
1 2 2
2 3 1

样例输出 #1

0
0
1

样例 #2

样例输入 #2

5
2 5 2
2 3 10
1 3 8
3 4 2

样例输出 #2

1
0
1
0
1

说明

数据规模与约定

  • 所有输入值均为整数。
  • 1N1051 \leq N \leq 10^5
  • 1ui<viN1 \leq u_i \lt v_i \leq N
  • 1wi1091 \leq w_i \leq 10^9