autumncloud8's blog

By autumncloud8, history, 7 years ago, In English

Problem: For a tree with n vertices. Every vertex has a value in range [1, c]. We define d(u, v) is number of distinct vertices's value on simple path from u to v, and . We have to calculate all sum(i), 1 ≤ i ≤ n.

Constraints: 1 ≤ n ≤ 100000, 1 ≤ c ≤ 300000.

Do you have any idea?

Full text and comments »

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