Please help for ARRGAME

Here is my code for ARRGAME , passing all the test cases , but still giving WA .
It would be of great help, if someone helps me by giving a suitable testcase which contradicts mine code .
Problem Link :
My Code :


Hello @sanjyathri :

1 1 0

Please check on above test, I think It is giving answer as “NO” But in this case, the player who plays first wins.

what if theres just one odd sized 0’s subarray? i think your code fails for that

Wrong testcases. Pardon me.

@ajay_5097 I guess, it is not a valid test case as there should be 1 at both starting and ending .

Problem statement did not say anything about the type of input.

It could be anything. based on that We need to devise a strategy IF POSSIBLE so that first player wins.

It is given in constraints that : A1 = An = 1

Output for 1st test case is giving “No” in mine code and second test case is not valid (I think so) as it is given in constraints that : A1 = An = 1 , so , there should be 1 at both starting and ending position .

How come you are checking this (odd[0]+1)/2) <= odd[1]). odd[1] may lead to segmentation fault.

Thank you for mentioning that. I did not notice that.

If you notice closely then there is always one strategy for the first player.
-> choose maximum segment of zeros and sit in the middle If n is odd.
-> If n is even, then he can sit on either position of that segment. (n/2), (n/2)-1
n = size of the maximum segment of zeros

But second player can play with two strategies.
-> either sit besides the first player so as to block all possible choices of one side
-> Or sit in completely different segment.

I can see both the strategies are independent of 1’s at both the ends.

But thank you for mentioning that.

Yeah, may be bcoz of this its giving WA , but it is strange that it is giving correct outputs on codechef compiler regarding this case on running manually.