Molekule
의견: 0
\(3^{rd}\) round, November \(28^{th}\) 2015
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.
In test cases worth at least 30% of total points, it will hold \(N\) ⩽20.
\(3^{rd}\) round, November \(28^{th}\) 2015
The first line of input contains the integer \(N\) (2 ⩽\(N\) ⩽100 000).
Each of the \(N - 1\) lines contains the integers \(a@@RISE_MATH_BLOCK_0@@i\) (1 ⩽\(a@@RISE_MATH_BLOCK_1@@i\)
and \(b\)\(i\) 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
\(a@@RISE_MATH_BLOCK_0@@i\), otherwise it contains 0.
If there are multiple possible solutions, output any.
3
1 2
2 3
0
1
4
2 1
1 3
4 1
1
0
1
평가 및 의견
Molekule
Log in to rate problems.
아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.
풀이 제출
Molekule