/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 12ms 580.0 KiB
#3 Accepted 6ms 568.0 KiB
#4 Accepted 6ms 564.0 KiB
#5 Accepted 20ms 324.0 KiB
#6 Accepted 20ms 532.0 KiB

Code

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef pair<long long,long long> PLL;

#define int long long
#define all(v) v.begin(),v.end()
#define faster {ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}  

const LL mod = 1e9 + 7;
const int N = 2e5 + 10;
const LL inf = 1e9;

bool get(int a, int b){
    int x = a, y = b;
    int lr = 1, lh = 0, mv = 1, ret = 1, fl = 1;
    while(a > 0 || b > 0){
        if(mv){
            if(lr){
                if(a) a--, lr = 0;
                else{fl = 0; break;}
            }else{
                if(b) b--, lr = 1;
                else {fl = 0; break;}
            }
        }else{
            if(lh){
                if(a) a--, lh = 0;
                else{fl = 1; break;}
            }else{
                if(b) b--, lh = 1;
                else{fl = 1; break;}
            }
        }
        mv ^= 1;
    }
    if(mv) fl = 0;
    ret &= fl;
    a = x, b = y, lr = 1, lh = 1, mv = 1, fl = 1;
    while(a > 0 || b > 0){
        if(mv){
            if(lr){
                if(a) a--, lr = 0;
                else{fl = 0; break;}
            }else{
                if(b) b--, lr = 1;
                else {fl = 0; break;}
            }
        }else{
            if(lh){
                if(a) a--, lh = 0;
                else{fl = 1; break;}
            }else{
                if(b) b--, lh = 1;
                else{fl = 1; break;}
            }
        }
        mv ^= 1;
    }
    if(mv) fl = 0;
    ret &= fl;
    return ret;
}

void solve(int test){
    int n; cin>>n;
    int o = 0, e = 0;
    for(int i = 0; i < n; i++){
        int u; cin>>u;
        if(u & 1) o++;
        else e++;
    }
    if(get(o, e) || get(e, o)) cout<<"Roy\n";
    else cout<<"Hridoy\n";
}

signed main(){
    faster
    int t = 1; 
    cin>>t;
    for(int i = 1; i <= t; i++){
        solve(i);
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1102 Odd-Even Game
Contest
Brain Booster #6
Language
C++17 (G++ 13.2.0)
Submit At
2024-10-03 16:39:06
Judged At
2024-11-11 02:47:55
Judged By
Score
100
Total Time
20ms
Peak Memory
580.0 KiB