judge solution: CENS20E - Editorial
my solution: https://www.codechef.com/viewsolution/37002426
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: https://www.codechef.com/viewsolution/37007805
My AC code: https://www.codechef.com/viewsolution/37008403
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.
4 6 9 10 2
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
thanks …got AC