/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 332.0 KiB
#2 Accepted 23ms 568.0 KiB
#3 Accepted 10ms 564.0 KiB
#4 Accepted 9ms 552.0 KiB
#5 Accepted 32ms 564.0 KiB
#6 Accepted 32ms 328.0 KiB

Code

#include<bits/stdc++.h>
#define endl        '\n'
#define F           first
#define S           second
#define pb          push_back
#define yes         cout<<"YES\n"
#define no          cout<<"NO\n"
#define all(x)      x.begin(),x.end()
#define allr(x)     x.rbegin(),x.rend()
#define error1(x)   cerr<<#x<<" = "<<(x)<<endl
#define error2(a,b) cerr<<"("<<#a<<", "<<#b<<") = ("<<(a)<<", "<<(b)<<")\n";
#define coutall(v)  for(auto &it: v) cout << it << " "; cout << endl;
using namespace std;
using ll = long long;
using ld = long double;

short OK(ll n, vector<ll> v, bool xx, bool xx2) {
    short op1 = -1, op2 = -1;
    bool op = 1;
    for(int i = 0; i < n; i++) {
        // cout << i << " => " << op1 << " " << op2 << endl;
        if(op) {
            if(op1 == -1) {
                if(xx == 1) {
                    if(v[1] == 0) {
                        return -1;
                    }
                    op1 = 1;
                    v[1] -= 1;
                }
                else {
                    if(v[0] == 0) {
                        return -1;
                    }
                    op1 = 0;
                    v[0] -= 1;
                }
            }
            else {
                op1 ^= 1;
                if(v[op1] == 0) {
                    return 0;
                }
                v[op1] -= 1;
            }
        }
        else {
            if(op2 == -1) {
                if(xx2 == 1) {
                    if(v[1] == 0) {
                        return -1;
                    }
                    op2 = 1;
                    v[1] -= 1;
                }
                else {
                    if(v[0] == 0) {
                        return -1;
                    }
                    op2 = 0;
                    v[0] -= 1;
                }
            }
            else {
                op2 ^= 1;
                if(v[op2] == 0) {
                    return 1;
                }
                v[op2] -= 1;
            }
        }
        op ^= 1;
        // cout << i << " => " << op1 << " " << op2 << endl;
    }
    if(!op) return 1;
    else return 0;
}

void solve() {
    ll n;
    cin >> n;
    vector<ll> v(2);
    for (int i = 0; i < n; i++) {
        ll x; cin >> x;
        v[x & 1] += 1;
    }
    // cout << OK(n, v, 0, 0) << endl;
    // cout << OK(n, v, 0, 1) << endl;
    // cout << OK(n, v, 1, 0) << endl;
    // cout << OK(n, v, 1, 1) << endl;
    ll a = OK(n, v, 0, 0);
    ll b = OK(n, v, 0, 1);
    ll c = OK(n, v, 1, 0);
    ll d = OK(n, v, 1, 1);
    if((a == 1 && b == 1) or (a == -1 && b == 1) or (a == 1 && b == -1) or (c == 1 && d == 1) or (c == -1 && d == 1) or (c == 1 && d == -1)) cout << "Roy" << endl;
    else cout << "Hridoy" << endl;
    return;
}

signed main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int tc = 1;
    cin >> tc;
    for (int t = 1; t <= tc; t++) {
        // cout << "Case " << t << ": ";
        solve();
    }
    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 17:39:41
Judged At
2024-12-17 11:32:32
Judged By
Score
100
Total Time
32ms
Peak Memory
568.0 KiB