/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 324.0 KiB
#2 Accepted 12ms 600.0 KiB
#3 Accepted 6ms 564.0 KiB
#4 Accepted 6ms 396.0 KiB
#5 Accepted 20ms 320.0 KiB
#6 Accepted 19ms 560.0 KiB

Code

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

void solve() {
  int n, a, oc = 0, ec = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (a % 2) oc++;
    else ec++;
  }

  auto check = [](int pr, int ph, int oc, int ec) {
    while (true) {
      int& tr = pr? oc : ec;
      if (!tr) return 0;
      tr--;
      pr = 1 - pr;

      int& th = ph? oc : ec;
      if (!th) return 1;
      th--;
      ph = 1 - ph;
    }
  };

  int r = check(0, 0, oc, ec) & check(0, 1, oc, ec);
  r |= check(1, 0, oc, ec) & check(1, 1, oc, ec);
  cout << (r? "Roy" : "Hridoy") << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
  cin >> t;
  while (t--)
    solve();
}

Information

Submit By
Type
Submission
Problem
P1102 Odd-Even Game
Language
C++17 (G++ 13.2.0)
Submit At
2024-10-09 12:08:17
Judged At
2024-11-11 02:38:12
Judged By
Score
100
Total Time
20ms
Peak Memory
600.0 KiB