Accepted
Code
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define endl '\n'
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds; // find_by_order, order_of_key
#define all(v) v.begin(), v.end()
#define pb push_back //
#define mp make_pair
#define fi first //
#define se second //
#define yes cout << "YES" << endl //
#define no cout << "NO" << endl //
#define M 1000000007 // 1e9+7
#define gcd(a, b) __gcd(a, b) //
#define lcm(a, b) a *b / gcd(a, b) //
#define memz(a) memset(a, 0, sizeof(a)) //
#define memn(a) memset(a, -1, sizeof(a)) //
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll tst;
cin>>tst;
for(ll test=1;test<=tst;test++)
{
//cout<<"Case "<<test<<": ";
ll n;
cin>>n;
ll x=0,y=0;
for(int i=0;i<n;i++)
{
ll t;
cin>>t;
if(t%2)y++;
else x++;
}
ll move=0;
ll even=x,odd=y;
bool c1=1,c2=1;
bool win=true;
while(1)
{
if(move%2==0)
{
if(c1==1)
{
if(even>0)
{
even--;
}
else break;
}
else
{
if(odd>0)
{
odd--;
}
else break;
}
c1=!c1;
}
else
{
if(c2==1)
{
if(even>0)
{
even--;
}
else break;
}
else
{
if(odd>0)
{
odd--;
}
else break;
}
c2=!c2;
}
move++;
}
if(move%2==0)win=false;
move=0;
even=x,odd=y;
c1=1,c2=0;
while(1)
{
if(move%2==0)
{
if(c1==1)
{
if(even>0)
{
even--;
}
else break;
}
else
{
if(odd>0)
{
odd--;
}
else break;
}
c1=!c1;
}
else
{
if(c2==1)
{
if(even>0)
{
even--;
}
else break;
}
else
{
if(odd>0)
{
odd--;
}
else break;
}
c2=!c2;
}
move++;
}
if(move%2==0)win=false;
if(win==true)
{
cout<<"Roy"<<endl;
continue;
}
move=0;
even=x,odd=y;
c1=0,c2=1;
win=true;
while(1)
{
if(move%2==0)
{
if(c1==1)
{
if(even>0)
{
even--;
}
else break;
}
else
{
if(odd>0)
{
odd--;
}
else break;
}
c1=!c1;
}
else
{
if(c2==1)
{
if(even>0)
{
even--;
}
else break;
}
else
{
if(odd>0)
{
odd--;
}
else break;
}
c2=!c2;
}
move++;
}
if(move%2==0)win=false;
move=0;
even=x,odd=y;
c1=0,c2=0;
while(1)
{
if(move%2==0)
{
if(c1==1)
{
if(even>0)
{
even--;
}
else break;
}
else
{
if(odd>0)
{
odd--;
}
else break;
}
c1=!c1;
}
else
{
if(c2==1)
{
if(even>0)
{
even--;
}
else break;
}
else
{
if(odd>0)
{
odd--;
}
else break;
}
c2=!c2;
}
move++;
}
if(move%2==0)win=false;
if(win==true)
{
cout<<"Roy"<<endl;
continue;
}
cout<<"Hridoy"<<endl;
}
}
Information
- Submit By
- Type
- Submission
- Problem
- P1102 Odd-Even Game
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2024-10-05 06:19:01
- Judged At
- 2024-11-11 02:40:31
- Judged By
- Score
- 100
- Total Time
- 20ms
- Peak Memory
- 588.0 KiB