#ABC126D. Even Relation
Even Relation
题目描述
We have a tree with vertices numbered to . The -th edge in the tree connects Vertex and Vertex , and its length is . 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.
我们有一棵树,树上有 个顶点,编号从 到 。树中的 条边连接顶点 和顶点 ,其长度为 。您的目标是将树中的每个顶点涂成白色或黑色(将所有顶点涂成相同颜色也可以),从而满足以下条件:
- 对于任何两个涂成相同颜色的顶点,它们之间的距离都是偶数。
找出满足条件的顶点颜色并打印出来。可以证明,在此问题的限制条件下,至少存在一个这样的着色。
输入格式
输入内容按以下格式标准输入:
输出格式
以 行打印满足条件的顶点着色。如果顶点 被涂成白色,则 行应包含 "0";如果顶点 被涂成黑色,则 行应包含 "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
说明
数据规模与约定
- 所有输入值均为整数。