Distinct Colors in a Subtree
Each node of a tree rooted at 1 has a color. For each query node x print how many distinct colors appear in the subtree of x.
Constraints
1 <= n, q <= 10^5 1 <= color <= n
Discussion
No discussions yet.
Shalyam Support
Hi! Ask us anything — we'll reply on WhatsApp or Telegram within 24 hours.