QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 256 MB Total points: 100

#1997. Circus

統計

The $N$ cows of Farmer John's Circus ($1 \leq N \leq 10^5$) are preparing their upcoming acts. The acts all take place on a tree with vertices labeled $1\ldots N$. The "starting state" of an act is defined by a number $1 \leq K \leq N$ and an assignment of cows $1\dots K$ to the vertices of the tree, so that no two cows are located at the same vertex.

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 $1 \leq K \leq N$, help the cows determine the number of equivalence classes of starting states: that is, the maximum number of starting states they can pick such that no two are equivalent. Since these numbers may be very large, output their remainders modulo $10^9 + 7$.

INPUT FORMAT (file circus.in):

Line $1$ contains $N$.

Lines $2\le i\le N$ each contain two integers $a_i$ and $b_i$ denoting an edge between $a_i$ and $b_i$ in the tree.

OUTPUT FORMAT (file circus.out):

For each $1\le i\le N,$ the $i$-th line of output should contain the answer for $K=i$ modulo $10^9+7$.

SAMPLE INPUT:

5
1 2
2 3
3 4
3 5

SAMPLE OUTPUT:

1
1
3
24
120

For $K=1$ and $K=2,$ any two states can be transformed into one another.

Now consider $K=3$, and let $c_i$ denote the location of cow $i$. The state $(c_1,c_2,c_3)=(1,2,3)$ is equivalent to the states $(1,2,5)$ and $(1,3,2).$ However, it is not equivalent to the state $(2,1,3).$

SAMPLE INPUT:

8
1 3
2 3
3 4
4 5
5 6
6 7
6 8

SAMPLE OUTPUT:

1
1
1
6
30
180
5040
40320

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

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.