Stuck at a simple problem

Can someone explain why my solution is wrong ?

problem : CodeChef | Competitive Programming | Participate & Learn
solution : CodeChef | Competitive Programming | Participate & Learn

your code failed in this case:

1 2 2

should be Marichka. Marichka take 1, no matter what Zenyk take, Marichka will win

1 Like

#include <bits/stdc++.h>
using namespace std;
int main()
int t;
cin >> t;
while (t–)
int n;
int a[n];
for(int i=0;i<n;i++)cin>>a[i];
int flag=1;
for(int i=n-1;i>=0;i–)mp[a[i]]++;
else cout<<“Marichka\n”;

return 0;

why this not running and why editorial is checking for all elements if if can see only the count of largest element if odd then marchika and if even then zenyk…

send link to your solution

thanks @henrychen . My logic was wrong.