結果

問題 No.2814 Block Game
ユーザー pockyny
提出日時 2025-07-19 06:44:47
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 461 ms / 2,000 ms
コード長 1,415 bytes
コンパイル時間 954 ms
コンパイル使用メモリ 78,632 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-07-19 06:45:00
合計ジャッジ時間 12,457 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>

using namespace std;
typedef long long ll;
#include <set>
// 残りの奇数/残りの偶数/空きマスで1の数/空きマスで0の数
ll calc(ll x,ll y,ll u,ll v,ll val,string s){
    if(x==0 && y==0){
        if(val&1){
            if(s=="Odd") return 1;
            else return 0;
        }else{
            if(s=="Odd") return 0;
            else return 1;
        }
    }
    set<ll> se;
    if(x && u) se.insert(calc(x - 1,y,u - 1,v,val^1,s));
    if(x && v) se.insert(calc(x - 1,y,u,v - 1,val^1,s));
    if(y && u) se.insert(calc(x,y - 1,u - 1,v,val,s));
    if(y && v) se.insert(calc(x,y - 1,u,v - 1,val,s));
    ll c = 0;
    while(se.count(c)) c++;
    return c;
}

int main(){
    // for(int i=1;i<=14;i++){
    //     int j = __builtin_popcount(i);
    //     int k = 1<<j;
    //     cout << i << " " << calc((i + 1)/2,i/2,k,i + 1 - k,0,"Odd") << "\n";; 
    // }
    int t; cin >> t;
    while(t){
        t--;
        ll n; string s; cin >> n >> s;
        ll x = n;
        while(!(x&1)) x /= 2;
        if(x==1){
            if(n<=2){
                if(s=="Odd") cout << "Alice\n";
                else cout << "Bob\n";
            }else{
                if(s=="Odd") cout << "Bob\n";
                else cout << "Alice\n";
            }
        }else if(n&1){
            cout << "Alice\n";
        }else{
            cout << "Bob\n";
        }
    }
}
0