Problem: https://www.codechef.com/CENS2020/problems/CENS20E

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.

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