PROBLEM LINK:
Author: Riddhish Lichade
Tester: Prathamesh Sogale
Editorialist: Ram Agrawal
DIFFICULTY:
EASY
PREREQUISITES:
Strings, Logic-maths
PROBLEM:
Meena and Vaibhav are suspects in a murder case and are bought in front of a judge.
The judge has his way of giving justice. Whenever the case involves two suspects, he announces his verdict based on a game. He gives a binary string S of length N to the suspects. A binary string consists only of "1"s and "0"s. Each suspect plays in alternate turns. In every turn the player must choose any index 1≤i≤N1≤i≤N such that Si≠Si+1Si≠Si+1 and delete SiorSi+1SiorSi+1 from the string. The player who is unable to make his move loses the game.
Determine the criminal if Meena plays first.
EXPLANATION:
First, count the number of 0s and 1s in the given binary string. If any of them is 0 then the answer is Meena. If the minimum of them is 1, then answer is Vaibhav. After covering these base cases if N is even then output is Meena else Vaibhav.
SOLUTIONS:
Setter's Solution
for _ in range(int(input())):
n = int(input())
s = input()
k = s.count('1')
r = min(k,n-k)
if r==0:
print('Meena')
elif r==1:
print('Vaibhav')
elif n%2==0:
print('Meena')
else:
print('Vaibhav')