I was upsolving problem 573C - Bear and Drawing.
My solution 12772765 got wa12.
But after I shuffled nodes it got AC.
Difference is only in line random_shuffle(q.begin(), q.end());
After that I fixed a bug, and solved it honestly 12773232. But imho tests are a little bit weak.
Can you explain your approach ?
Here is a drawing with all cases. I used a similar approach 12760713.
Yes, that's true. If you know types of all son vertices, you can get the type of father vertice.