/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 11ms 580.0 KiB
#3 Accepted 6ms 532.0 KiB
#4 Accepted 5ms 532.0 KiB
#5 Accepted 18ms 532.0 KiB
#6 Accepted 18ms 768.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int T;
    cin >> T;
    while (T--) {
        int N;
        cin >> N;
        int E = 0, O = 0;
        for (int i = 0; i < N; i++) {
            int x;
            cin >> x;
            if (x & 1) ++O;
            else       ++E;
        }

        int d = abs(E - O);
        bool roy;
        if (d == 1) {
            // difference exactly 1 → Roy can always force the alternation
            roy = true;
        }
        else if (d >= 2) {
            // if one color is “large enough” and the smaller pile is odd,
            // Roy can exhaust it on Hridoy’s turn
            roy = (min(E, O) % 2 == 1);
        }
        else {
            // d == 0 → perfectly balanced → Hridoy wins
            roy = false;
        }

        cout << (roy ? "Roy\n" : "Hridoy\n");
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1102 C. Odd-Even Game
Language
C++17 (G++ 13.2.0)
Submit At
2025-05-14 16:11:59
Judged At
2025-05-14 16:11:59
Judged By
Score
100
Total Time
18ms
Peak Memory
768.0 KiB