/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 51ms 576.0 KiB
#3 Accepted 18ms 320.0 KiB
#4 Accepted 15ms 580.0 KiB
#5 Accepted 61ms 1.297 MiB
#6 Accepted 61ms 1.062 MiB

Code

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

bool r_wins(ll n,ll even, ll odd,ll roy_curr_parity,ll hri_curr_parity ){
    for(int i=0; i<=n; i++){
        if(i%2==0){
            if(roy_curr_parity%2==0){
                if(even==0)return 0;
                even--;
                roy_curr_parity=1;
            }
            else{
                if(odd==0)return 0;
                odd--;
                roy_curr_parity=0;
            }
        }
        else{
            if(hri_curr_parity%2==0){
                if(even==0)return 1;
                even--;
                hri_curr_parity=1;
            }
            else{
                if(odd==0) return 1;
                odd--;
                hri_curr_parity=0;
            }
        }
    }
    return false;
}

void solve(){
    ll n;
    cin>>n;
    vector<ll> arr(n);
    int even=0,odd=0;
    for(ll i=0; i<n; i++){
        cin>>arr[i];
        if(arr[i]%2==0){
            even++;
        }
        else{
            odd++;
        }
    }
    if(r_wins(n,even,odd,0,0) && r_wins(n,even,odd,0,1)){
        cout<<"Roy"<<endl;
        return;
    }
    if(r_wins(n,even,odd,1,0) && r_wins(n,even,odd,1,1)){
        cout<<"Roy"<<endl;
        return;
    }
    cout<<"Hridoy"<<endl;
    
}
int main(){
    int t;
    cin>>t;
    while(t--){
        solve();
    }
return 0;
}

Information

Submit By
Type
Submission
Problem
P1102 Odd-Even Game
Language
C++17 (G++ 13.2.0)
Submit At
2024-10-04 05:35:05
Judged At
2024-11-11 02:43:24
Judged By
Score
100
Total Time
61ms
Peak Memory
1.297 MiB