AtCoder Beginner Contest 198 Problem E - Unique Color

Please provide me a detail editorial of problem E - Unique Color with solution.
Thanks in advance

https://atcoder.jp/contests/abc198/submissions/21688185
Here is my code for the problem you mentioned.
So what i did basically is that i performed a DFS on the tree and kept the colors of the nodes to which i went in a multiset, Why DFS because the given graph is a tree and there won’t be any cycles in it so we can be sure that the shortest paths for any node from root node(here node 1) will be the path traced using DFS traversal of node.
Also whenever we reach a leaf node we remove its color from the multiset because once
we are at a leaf node the dfs will go back to parent and then to other child so that’s why we need to delete the color of the leaf node.
Try thinking it by tracing the DFS traversal of the tree that will make it more clear for you.

For this u have to do only DFS , once a node is visited after doing DFS from that node u have to erase that colour of that node .
submission link : Submission #21735343 - AtCoder Beginner Contest 198

Can someone please look into my solution, I am not able to figure out what went wrong. Solution Link