AtCoder Beginner Contest-199 Problem D

hello codechef community, the problem for which I’m seeking help in is “RGB Coloring 2” problem no. D from atcoder beg. contest-199.
The problem has got use dfs. Although I’m quite familiar with graph theory but still not able to understand any of the tutorial or editorial. In fact the thing is that the idea behind this problem’s solution is not clicking in my mind so I’m not understanding anyone’s code as well.
Can anyone please help me understand what is whole idea behind it…and also please help me with your code along with.
Here is the link of problem: RGB Coloring 2

Thank You.

1 Like