T1 color
I quickly thought of an O (n 2) O(n^2)O ( n2 )The practice deceived 50 points.
Although it is stated in the problem solution that the correct solution is optimized from the method of the n-square, the method I think is very different from the method of the problem solution and cannot be optimized at all:
The colors that must appear are regarded as the inclusion relationship between intervals, so it is similar to a bracket sequence, and each color has a left boundary and a right boundary. Think of it as adding a point on the tree, and then record the number of leaf nodes, remove the point 1 and treat it as point 0, which is convenient for calculating the answer. Let dp[i][j] be the occurrence of i colors, that is, when there are i+1 points in the tree, j is the number of leaf schemes, then the newly added point has two possibilities, and it becomes the previous point The oldest brother, or the eldest son at a certain point, dp [i] [j] = dp [i − 1] [j] ∗ j + dp [i − 1] [j − 1] ∗ (2 ∗ i − j) dp[i][j]=dp[i-1][j] * j + dp[i-1][j-1] * (2*ij)dp[i][j]=dp[i−1][j]∗j+dp[i−1][j−1]∗(2∗i−j ) , and then the contribution to the answer isdp [i] [j] ∗ C (n − 1, i − 1) ∗ C (m + j, i ∗ 2) dp[i][j] * C(n- 1,i-1) * C(m+j,i*2)dp[i][j]∗C(n−1,i−1)∗C(m+j,i∗2 )
This approach is the same asn 2 n^2n2 tightly binding, can not be optimized.
T2 fenwick
I didn't push it carefully, so I believed a wrong conclusion for an hour and a half. In the end, I didn't even hit the most obvious violence and only scored 10 points.
T3 gift
I don’t know the polya theorem, I don’t know Burnside’s lemma, and I’m not good at fighting violence, so I only got 5 points.