/ SeriousOJ /

Record Detail

Accepted


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

Code

#include <iostream>
using namespace std;

bool can_win(int f_ev, int s_ev, int ev, int od) {
  int turn = 1;
  while (true) {
    if (turn) { f_ev ? ev-- : od--; f_ev ^= 1; }
    else { s_ev ? ev-- : od--; s_ev ^= 1; }
    turn ^= 1;
    if (ev < 0 || od < 0) return turn;
  }
  return 0;
}

void solve() {
  int n; cin >> n;
  int ev = 0, od = 0;
  for (int i = 0; i < n; i++) {
    int x; cin >> x; (x & 1) ? od++ : ev++;
  }

  bool ok = false;
  for (int i = 0; i < 2; i++) {
    bool win = true;
    for (int j = 0; j < 2; j++)
      win &= can_win(i, j, ev, od);
    ok |= win;
  }
  cout << (ok ? "Roy" : "Hridoy") << '\n';
}

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  int tt; cin >> tt; while (tt--) solve(); return 0;
}

Information

Submit By
Type
Submission
Problem
P1102 Odd-Even Game
Language
C++17 (G++ 13.2.0)
Submit At
2024-10-03 20:56:40
Judged At
2024-11-11 02:44:23
Judged By
Score
100
Total Time
20ms
Peak Memory
580.0 KiB