Priya and Parity...Why got WA?

judge solution: CENS20E - Editorial
my solution:
i think i did almost same way…but i got WA. what’s wrong in my code ? please help me to find out…thanks

My WA code:
My AC code:
I used the same logic as you did and got WA. Initially, I considered each component and counted the number of odd and even cities. But for my AC code, I considered the odd cities and even cities in the same connected component as different components.

the way u are counting connected components is wrong.
try this
5 4
4 6 9 10 2
1 2
1 3
1 4
2 5
0(queries-let it be any value)
ur even value is 2 (it should be 1)
ur odd value is 3(it shoud be also 1)
consider connected components only not all

1 Like

thanks …got AC