MathLimitExceeded's blog

By MathLimitExceeded, history, 10 years ago, In English

I was trying to solve problem A from the recently conducted ICPC regional contest.

My approach was to use the following DP transition state — dp(i)(j) denotes the number of ways to assign labels to the subtree rooted at node i such that node i is given the label j.

I came up with the following transition for this state

where is the binomial coefficient, li and ri are the left and right child of i and si denotes the size of the sub-tree rooted at i.

According to me the time complexity of this algorithm is if I use prefix and suffix sums in the summation but it seems that this solution gets accepted. Can someone help show me how?

  • Vote: I like it
  • +11
  • Vote: I do not like it

»
10 years ago, hide # |
 
Vote: I like it +5 Vote: I do not like it

WLOG, assume sli ≤ sri. Also, notice that k ≤ sli.
Also, si = sli + sri + 1 = O(sri)

Then, total number of computations

Notice that