#1227
Unrated
MOLEKULE
스페셜 저지채점 준비중
시간 제한
1s
메모리 제한
64MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

1 second, 64 MB, 100 points Scientists in a chemical lab in Croatia have been studying the chemical bonds between different mole- cules. They have a special interest in a group of molecules of the chemical compound nitro hydrogen laminate. The compound consists of N molecules bound together by N −1 covalent bonds and all the molecules are directly or indirectly tied together with bonds in a single structure. The scientists want to modify the compound in a way that all the covalent bonds are transformed into directed covalent bonds. Because of the instability of the newly created compound, each molecule will have a large number of impulses coming out of it and travelling to other molecules using the directed bonds. An impulse can travel using the directed covalent bond only in the direction of the bond itself. The instability of the compound is defined as the largest possible number of bonds a single impulse can use to travel. The scientists want to direct the compound’s covalent bonds in a way that the newly created compound is as stable as possible. In other words, their goal is to create a compound with the minimal longest path an impulse can take during its travel. Help the scientists determine the direction of each covalent bond in the compound.

입력

The first line of input contains the integer N (2 ⩽N ⩽100 000). Each of the N −1 lines contains the integers ai and bi (1 ⩽ai, bi ⩽N) that denote that molecules ai and bi are connected with a covalent bond.

출력

Output N −1 lines, where each line must contain 1 if the covalent bond is going to be directed from ai to bi, otherwise it contains 0. If there are multiple possible solutions, output any.

예제 입력 1

3
1 2
2 3

예제 출력 1

0
1

예제 입력 2

4
2 1
1 3
4 1

예제 출력 2

1
0
1
코드 제출

이 문제는 현재 제출할 수 없습니다.

이 현상이 잘못되었다고 생각될 경우 관리자한테 문의주세요.

내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.