John and Joe are playing a game. Initially, they have a string of length n consisting of zeros and ones only. Both the players are playing game optimally taking alternate turns. In each turn, the player removes only one occurrence of either substring "01" or "10" from anywhere in the given binary string. The player who cannot make a move loses the game. If John makes the first move, he wonders who will win the game. You, being his friend, help him solve his problem.
Answers
Answer:
Ggle
Explanation:
Mark me Brainliest and follow
Input Format
1. The number of test cases is indicated on the first line by the integer .
2. Each test case starts with an integer , which represents the string's length.
3. The second line of each test case contains the initial string.
Constraints
1. ≤ ≤
2. ≤ ≤
3. It is certain that the initial string will only include zeros and ones.
Output Format
If John wins the game, display "John" in a new line for each test case; otherwise, print "Joe."
Sample Input
Sample Output
John
Joe
Program Code
int main()
{
int ;
cin>>;
while()
{
int ;
string ;
cin>>;
cin>>;
queue<char> ;
int ;
while(){
;
;
}
bool ;
int ;
;
while(&& ){
char = ;
;
char ;
;
if(( &&) || (&&))
{
;
;
;
} else{
;
;
;
}
}
if cout<<"Joe"<<endl;
else cout<<"John"<<endl;
;
}
return ;
}
Hence, the above program code allows you to find out who will win the game.
#SPJ3