# Priya and Parity...Why got WA?

**URL:** <https://discuss.codechef.com/t/priya-and-parity-why-got-wa/75464>\
**Category:** help\
**Tags:** c-plus-plus\
**Created:** [August 20, 2020, 2:33am UTC](https://discuss.codechef.com/t/priya-and-parity-why-got-wa/75464 "2020-08-20T02:33:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![naeem4265](https://discuss.codechef.com/user_avatar/discuss.codechef.com/naeem4265/32/3653_2.png) [@naeem4265](https://discuss.codechef.com/u/naeem4265)\
**Post date:** [August 20, 2020, 2:33am UTC](https://discuss.codechef.com/t/priya-and-parity-why-got-wa/75464/1 "2020-08-20T02:33:14Z")

</div>

Problem: [CodeChef: Practical coding for everyone](https://www.codechef.com/CENS2020/problems/CENS20E)  
judge solution: [CENS20E - Editorial](https://discuss.codechef.com/t/cens20e-editorial/75412)  
my solution: [CodeChef: Practical coding for everyone](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**

---

<div class="post-metadata">

**Author:** ![therealnishuz](https://discuss.codechef.com/user_avatar/discuss.codechef.com/therealnishuz/32/169792_2.png) [@therealnishuz](https://discuss.codechef.com/u/therealnishuz)\
**Post date:** [August 20, 2020, 3:01am UTC](https://discuss.codechef.com/t/priya-and-parity-why-got-wa/75464/2 "2020-08-20T03:01:07Z")

</div>

My WA code: [CodeChef: Practical coding for everyone](https://www.codechef.com/viewsolution/37007805)  
My AC code: [CodeChef: Practical coding for everyone](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.

---

<div class="post-metadata">

**Author:** ![deadman\_002](https://discuss.codechef.com/user_avatar/discuss.codechef.com/deadman_002/32/208155_2.png) [@deadman\_002](https://discuss.codechef.com/u/deadman_002)\
**Post date:** [August 20, 2020, 3:09am UTC](https://discuss.codechef.com/t/priya-and-parity-why-got-wa/75464/3 "2020-08-20T03:09:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![naeem4265](https://discuss.codechef.com/user_avatar/discuss.codechef.com/naeem4265/32/3653_2.png) [@naeem4265](https://discuss.codechef.com/u/naeem4265)\
**Post date:** [August 20, 2020, 3:36am UTC](https://discuss.codechef.com/t/priya-and-parity-why-got-wa/75464/4 "2020-08-20T03:36:58Z")

</div>

thanks …got AC
