Problem A Codeforces DIV 3 : Where am I going wrong? [SOLVED]

Jesus christ, this ultra easy problem ruined the contest for me :stuck_out_tongue:

What’s the difference b/w this submission and my submission?

I still don’t get it. lol.

I am not able to understand your code:
But there are two cases:
if(n is even) {
at least one odd and at least one even number is present answer is yes.
}
if(n is odd){
at least one odd is present answer is yes.
}
answer is no if none of the above case is true

By this I mean.

 if eve and odd:
     print('YES')
     return

If both even and odd numbers are present in array, then I print “YES” else no.

It’s pretty similar to

if((sum&1)||(odd&&even)){
	printf("YES\n");
}

If the sum is already odd, no need to do anything.
sum&1 corresponds to sum(arr) % 2 == 1 which I already took care of earlier in my code. I hope you get what I’m saying?

Both the above codes use the same logic. One got accepted and other didn’t. I’ve done something silly, but I can’t figure out what.

You assign n all rows of length one, but you do not take into account the case when the array consists of one element
if len(temp) == 1:
n = temp[0]

Yep, got the bug… It was while I was taking input. Indeed it was silly. Thanks. Will keep this in mind next time.

Will use an alternating variable while taking standard input from file now onwards. Here’s the stupid fix.

I’m glad that at least my logic wasn’t wrong

1 Like