White-Black Balanced Subtrees solution codeforces

You are given a rooted tree consisting of 𝑛n vertices numbered from 11 to 𝑛n. The root is vertex 11. There is also a string 𝑠s denoting the color of each vertex: if 𝑠𝑖=𝙱si=B, then vertex 𝑖i is black, and if 𝑠𝑖=𝚆si=W, then vertex 𝑖i is white. White-Black Balanced Subtrees solution codeforces A subtree of the tree is called balanced if the number of white vertices equals the number … Read more