/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 3ms 520.0 KiB
#2 Accepted 22ms 608.0 KiB
#3 Accepted 14ms 560.0 KiB
#4 Accepted 11ms 560.0 KiB
#5 Accepted 40ms 564.0 KiB
#6 Accepted 42ms 556.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) {
      if (f_ev) {
        ev--;
      } else
        od--;
      f_ev ^= 1;
    } else {
      if (s_ev) {
        ev--;
      } else
        od--;
      s_ev ^= 1;
    }
    turn ^= 1;
    if (ev < 0 || od < 0)
      return turn;
  }
}

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++) {
    int win = 0;
    for (int j = 0; j < 2; j++) {
      win += can_win(i, j, ev, od);
    }
    ok |= (win == 2);
  }
  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:53:13
Judged At
2024-11-11 02:44:23
Judged By
Score
100
Total Time
42ms
Peak Memory
608.0 KiB