Priya and Parity...Why got WA?

Problem: CodeChef: Practical coding for everyone
judge solution: CENS20E - Editorial
my solution: CodeChef: Practical coding for everyone
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: CodeChef: Practical coding for everyone
My AC code: CodeChef: Practical coding for everyone
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
1
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