The palindrome Game

My code is getting wa…can anyone spot out the test case for which my code doesnt work?

http://www.codechef.com/viewsolution/3104883

http://www.codechef.com/viewsolution/3105683

check this… I have modified your program a little bit and now it works

the condition which u had put

            if(odd>1)
	break;

gives you a wrong solution
as it makes the program to break out of the loop in an untimely manner (i.e. doesnt check the entire string)

but if the string is “abcsa” Ram cant make palindrome so he should lose but you program says ram wins…

if the string is abcsa ram wins clearly
The question says "In one move the player can remove an arbitrary letter from string s.
If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. "

So for the example you provided
abcsa
1st turn : ram removes lets say b
2nd turn : shyam removes c
3rd turn : ram removes s to get a palindrome and therefore is the winner.

I hope its clear now :slight_smile:

Small mistake ritu , in the 3rd turn ram removes s so ‘before moving his turn shyam can rearrange and create a palin’ thus shyam wins

basically
eg aba nothing to do - ram wins
abca - ram needs to make one move and then shyam gets aba so shyam wins

even moves-ram wins
odd moves-shyam wins
i hope its clear :slight_smile:

//