/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Wrong Answer 10ms 596.0 KiB
#3 Wrong Answer 5ms 532.0 KiB
#4 Accepted 5ms 536.0 KiB
#5 Accepted 16ms 764.0 KiB
#6 Accepted 16ms 320.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;

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;
    }
    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(v[1] == 0 or (v[0] - 1 >= v[1])) {
                    op1 = 0;
                    v[0] -= 1;
                }
                else {
                    if(v[1] == 0) {
                        cout << "Hridoy" << endl;
                        return;
                    }
                    op1 = 1;
                    v[1] -= 1;
                }
            }
            else {
                op1 ^= 1;
                if(v[op1] == 0) {
                    cout << "Hridoy" << endl;
                    return;
                }
                v[op1] -= 1;
            }
        }
        else {
            if(op2 == -1) {
                if(v[1] == 0 or (v[0] - 1 >= v[1])) {
                    op2 = 0;
                    v[0] -= 1;
                }
                else {
                    if(v[1] == 0) {
                        cout << "Roy" << endl;
                        return;
                    }
                    op2 = 1;
                    v[1] -= 1;
                }
            }
            else {
                op2 ^= 1;
                if(v[op2] == 0) {
                    cout << "Roy" << endl;
                    return;
                }
                v[op2] -= 1;
            }
        }
        op ^= 1;
        // cout << i << " => " << op1 << " " << op2 << endl;
    }
    if(!op) 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 16:24:47
Judged At
2024-10-03 16:24:47
Judged By
Score
61
Total Time
16ms
Peak Memory
764.0 KiB