#P6147. [USACO20FEB] Delegation G
[USACO20FEB] Delegation G
Description
Farmer John has pastures, connected by roads, forming a tree.
But after 28 years of running the farm (translator's note: USACO was founded in 1992), FJ feels that dealing with tree problems is very troublesome, and he thinks problems on a single path are easier.
So he decides to split the whole tree into several chains, and give the management of each chain to a worker. To avoid possible disputes, he wants all chains to have the same length.
FJ now wants to know, for each satisfying , whether there exists a way to partition the entire tree into several chains such that every chain has length exactly .
Input Format
The first line contains an integer ().
The next lines each contain two integers (), describing a road connecting and .
Output Format
Output a 0/1 string of length . The -th character is if and only if there exists a partition plan such that the whole tree is partitioned into several chains and every chain has length exactly ; otherwise, the -th character is .
13
1 2
2 3
2 4
4 5
2 6
6 7
6 8
8 9
9 10
8 11
11 12
12 13
111000000000
Hint
Sample Explanation
When , there is a valid partition plan.
One valid partition plan for is:
Subtasks
- Test points satisfy that there is at most one node whose degree is greater than .
- Test points satisfy .
- Test points have no special constraints.
Translated by ChatGPT 5
京公网安备 11011102002149号