Problems
The
In an act, the cows make an arbitrarily large number of "moves." In a move, a single cow moves from her current vertex to an unoccupied adjacent vertex. Two starting states are said to be equivalent if one may be reached from the other by some sequence of moves.
For each
For
Now consider
SCORING:
Test cases 3-4 satisfy
N\le 8. Test cases 5-7 satisfy
N\le 16. Test cases 8-10 satisfy
N\le 100 and the tree forms a "star;" at most one vertex has degree greater than two.Test cases 11-15 satisfy
N\le 100 .Test cases 16-20 satisfy no additional constraints.
Problem credits: Dhruv Rohatgi
Input
Line
Lines
Output
For each
Example #1
5
1 2
2 3
3 4
3 5
1
1
3
24
120
For
Now consider
Example #2
8
1 3
2 3
3 4
4 5
5 6
6 7
6 8
1
1
1
6
30
180
5040
40320