# PJCYP IUPC Editorial

IUPC- PLINTH’20: https://www.codechef.com/PLIN2020/problems/PJCYP

Author: Pulkit Jain
Problem Tester: Priyam Khandelwal
Editorialist: Pulkit Jain

DIFFICULTY: Cakewalk

PROBLEM: There were N wooden planks kept in a row (The height of the ith plank is greater than or equal to the height of the previous plank). At every turn a player will select a number (height of the plank), if there are multiple occurrences of that plank then the first one among them and all the planks before it (index wise) are removed. The player who removes the last plank will be declared as the winner.

EXPLANATION:
In this game, the winner is decided only by counting the frequency of distinct heights of the planks and if there are odd number of planks of any height then Customer-A wins and otherwise B, because when they play optimally then A will try to select the plank whose frequency is odd so that he may remove the last plank and win the game.

SOLUTION:

Setter's Solution

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define FastIo ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//ll arr[10000007]={0};
int main()
{
FastIo
ll n;
cin>>n;
ll a;
map<ll,ll>mp;
for(int i=1;i<=n;i++)
{
cin>>a;
mp[a]++;
}
for(auto it : mp)
{
if(it.second%2!=0)
{
cout<<“Customer-A”<<endl;
return 0;
}
}
cout<<“Customer-B”<<endl;
return 0;
}

Can use unordered_map for making it more efficient