/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 3ms 1.27 MiB
#2 Accepted 244ms 1.359 MiB
#3 Accepted 30ms 1.316 MiB
#4 Accepted 7ms 1.312 MiB
#5 Accepted 18ms 1.309 MiB
#6 Accepted 18ms 1.273 MiB

Code

#include<bits/stdc++.h>
using namespace std;
const long long M =2e5+2,MOD=1e18;
typedef long long ll;
bool solve(int x,int y){
    if(x==0)return false;
    int roy=1;
    int hridoy=1;
    int tempx=x,tempy=y;
    while(1){
       if(roy){
        if(x==0)return false;
        x--;
       }
       if(roy==0){
        if(y==0)return false;
        y--;
       }
       if(hridoy){
        if(x==0)break;
         x--;
       }
       if(hridoy==0){
        if(y==0)break;
        y--;
       }
       roy^=1;
       hridoy^=1;
    }
    roy=1;
    hridoy=0;
    x=tempx;
    y=tempy;
     while(1){
       if(roy){
        if(x==0)return false;
        x--;
       }
       if(roy==0){
        if(y==0)return false;
        y--;
       }
       if(hridoy){
        if(x==0)break;
         x--;
       }
       if(hridoy==0){
        if(y==0)break;
        y--;
       }
       roy^=1;
       hridoy^=1;
    }
    return true;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        int odd=0,even=0;
        vector<int>aa(M,0);
        for(int i=1;i<=n;i++){
            int a;
            cin>>a;
            odd+=(a&1);
            even+=(a%2==0);
        }
        int x=0;
       // cout<<odd<<" "<<even<<endl;
        x|=solve(odd,even);
        x|=solve(even,odd);
        cout<<(x?"Roy\n":"Hridoy\n");
   
    }

    return 0;

}

Information

Submit By
Type
Submission
Problem
P1102 Odd-Even Game
Language
C++20 (G++ 13.2.0)
Submit At
2024-09-23 20:34:58
Judged At
2024-10-03 12:55:52
Judged By
Score
100
Total Time
244ms
Peak Memory
1.359 MiB