/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 516.0 KiB
#2 Wrong Answer 20ms 588.0 KiB
#3 Wrong Answer 9ms 560.0 KiB

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 even=0,odd=0;
        for(int i=0;i<n;i++)
        {
            ll t;
            cin>>t;
            if(t%2)odd++;
            else even++;
        }
        bool c1=1,c2=1;
        ll x=even,y=odd;
        ll choice=0;
        bool win=true;
        while (x>0&&y>0)
        {
            if(choice%2==0)
            {
                if(c1==1)x--;
                else y--;
                c1=!c1;
            }
            else
            {
                if(c2==1)x--;
                else y--;
                c2=!c2;
            }
            choice++;
        }
        if(choice%2==0)win=false;
        if(win==true)
        {
            x=even,y=odd;
            c1=1,c2=0;
            choice=0;
             while (x>0&&y>0)
             {
                 if (choice % 2 == 0)
                 {
                     if (c1 == 1)
                         x--;
                     else
                         y--;
                     c1 = !c1;
                 }
                 else
                 {
                     if (c2 == 1)
                         x--;
                     else
                         y--;
                     c2 = !c2;
                 }
                 choice++;
             }
             if (choice % 2 == 0)win = false;
        }
        if(win==true)
        {
            cout<<"Roy"<<endl;
            continue;
        }




         c1=0,c2=1;
         x=even,y=odd;
         choice=0;
         win=true;
        while (x>0&&y>0)
        {
            if(choice%2==0)
            {
                if(c1==1)x--;
                else y--;
                c1=!c1;
            }
            else
            {
                if(c2==1)x--;
                else y--;
                c2=!c2;
            }
            choice++;
        }
        if(choice%2==0)win=false;
        if(win==true)
        {
            x=even,y=odd;
            c1=0,c2=0;
            choice=0;
             while (x>0&&y>0)
             {
                 if (choice % 2 == 0)
                 {
                     if (c1 == 1)
                         x--;
                     else
                         y--;
                     c1 = !c1;
                 }
                 else
                 {
                     if (c2 == 1)
                         x--;
                     else
                         y--;
                     c2 = !c2;
                 }
                 choice++;
             }
             if (choice % 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 05:57:30
Judged At
2024-11-11 02:40:32
Judged By
Score
1
Total Time
20ms
Peak Memory
588.0 KiB