Tree's problem related to number of distinct vertices's value on simple path

Revision en1, by autumncloud8, 2017-12-25 15:50:30

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?

Tags tree, distinct value, shortest path, simple path

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English autumncloud8 2017-12-25 15:50:30 431 Initial revision (published)