M1v1savva's blog

By M1v1savva, history, 4 years ago, In English

The problem is the following:

Given a tree on $$$n$$$ vertices. For each $$$d = 1, 2, ..., n - 1$$$ find the number of paths of length $$$d$$$.

$$$n$$$ <= 50000, 5 seconds, 256 mb

I know how to solve similar problem with fixed $$$d$$$ using CD but have no clue how to solve this version. Could someone help?

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

»
4 years ago, # |
  Vote: I like it +45 Vote: I do not like it

You can use fft to calculate the number of paths of all lengths that go through the centroid.