I have not looked at your code, but my attempts at a solution also passed only the last test, so I guess we made the same mistake. When the first number in the sequence of A is 1, what does a player do on the last number of each round of N plays? Normally the best thing to do is to take an even number to stay there, so that the other player is forced to take the 1, and so not be able to take any more in that round. But when the total number of rounds R is 1 more than a multiple of N (R % N == 1), the player should take an odd number at the end of the last full round, and then take the final 1.

1 Like

Hi all and @utkarsh911 , Can someone please let me know what is wrong with my submission , I am getting subtask 1 task 0 and subtask 2 and task 2 as wrong answer . I have tried with multiple different testcases and I have also checked for all the testcases provided in the editorial. My solution is here:

https://www.codechef.com/viewsolution/39938632

It will help me a lot to check what went wrong , thanks