/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 324.0 KiB
#2 Accepted 12ms 588.0 KiB
#3 Accepted 6ms 576.0 KiB
#4 Accepted 6ms 532.0 KiB
#5 Accepted 20ms 1.312 MiB
#6 Accepted 21ms 1.312 MiB

Code

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

#define int long long
#define pi pair<int, int>
#define pii pair<int, pi>
#define fi first
#define se second
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, A[200005];

void solve(){
	cin >> n;
	for(int i = 1; i <= n; i++)cin >> A[i];
	int cnt0 = 0, cnt1 = 0;
	for(int i = 1; i <= n; i++){
		if(A[i] % 2)cnt1++;
		else cnt0++;
	}
	bool x[2][2];
	for(int a : {0, 1}){
		for(int b : {0, 1}){
			int c = cnt1, cc = cnt0;
			bool rv = 0, wn = 0;
			while(1){
				if(!rv){
					if(a == 0){
						if(cnt0)cnt0--;
						else break;
					}
					else{
						if(cnt1)cnt1--;
						else break;
					}
					if(b == 0){
						if(cnt0)cnt0--;
						else {
							wn = 1;
							break;
						}
					}
					else{
						if(cnt1)cnt1--;
						else {
							wn = 1;
							break;
						}
					}
				}
				else{
					if(a == 1){
						if(cnt0)cnt0--;
						else break;
					}
					else{
						if(cnt1)cnt1--;
						else break;
					}
					if(b == 1){
						if(cnt0)cnt0--;
						else {
							wn = 1;
							break;
						}
					}
					else{
						if(cnt1)cnt1--;
						else {
							wn = 1;
							break;
						}
					}
				}
				rv = !rv;
			}
			cnt0 = cc, cnt1 = c;
			x[a][b] = wn;
		}
	}
	//for(int i = 0; i < 2; i ++)for(int j = 0; j < 2; j++)cout << x[i][j] << ' ';
	if((x[0][0] && x[0][1]) || (x[1][0] && x[1][1]))cout << "Roy\n";
	else cout << "Hridoy\n";
}

main(){
	ios::sync_with_stdio(0);cin.tie(0);
	int tc = 1;
	cin >> tc;
	for(int tc1=1;tc1<=tc;tc1++){
		// cout << "Case #" << tc1 << ": ";
		solve();
	}
}

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 15:39:19
Judged At
2024-11-11 02:50:31
Judged By
Score
100
Total Time
21ms
Peak Memory
1.312 MiB