結果
問題 | No.2814 Block Game |
ユーザー | Rubikun |
提出日時 | 2024-07-19 22:55:26 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 54 ms / 2,000 ms |
コード長 | 2,510 bytes |
コンパイル時間 | 2,099 ms |
コンパイル使用メモリ | 202,000 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-19 22:55:32 |
合計ジャッジ時間 | 5,427 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 20 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; } #define all(x) (x).begin(),(x).end() #define fi first #define se second #define mp make_pair #define si(x) int(x.size()) const int mod=998244353,MAX=300005,INF=15<<26; bool comb[222][222]; bool seen[111][111][111][111][2]; bool ans[111][111][111][111][2]; bool solve(int A,int B,int C,int D,bool tar){ if(A+B==0){ if(tar) return false; else return true; } if(seen[A][B][C][D][tar]) return ans[A][B][C][D][tar]; bool res=false; seen[A][B][C][D][tar]=true; if(A){ if(C){ if(!solve(A-1,B,C-1,D,tar^1^1)) return ans[A][B][C][D][tar]=true; } if(D){ if(!solve(A-1,B,C,D-1,tar^0^1)) return ans[A][B][C][D][tar]=true; } } if(B){ if(C){ if(!solve(A,B-1,C-1,D,tar^0^1)) return ans[A][B][C][D][tar]=true; } if(D){ if(!solve(A,B-1,C,D-1,tar^0^1)) return ans[A][B][C][D][tar]=true; } } return ans[A][B][C][D][tar]=false; } int main(){ std::ifstream in("text.txt"); std::cin.rdbuf(in.rdbuf()); cin.tie(0); ios::sync_with_stdio(false); comb[0][0]=1; for(int i=0;i<=200;i++){ for(int j=0;j<=i;j++){ comb[i+1][j]^=comb[i][j]; comb[i+1][j+1]^=comb[i][j]; } } for(int n=0;n<=100;n++){ int A=0,B=0; for(int i=0;i<=n;i++){ if(comb[n][i]) A++; else B++; } int C=n/2+1,D=n+1-C; //cout<<n+1<<" "<<solve(A,B,C,D,1)<<" "<<solve(A,B,C,D,0)<<endl; } int Q;cin>>Q; while(Q--){ ll N;cin>>N; string S;cin>>S; if(S=="Odd"){ if(N<=3) cout<<"Alice\n"; else if(N&1) cout<<"Alice\n"; else cout<<"Bob\n"; }else{ if(N<=2) cout<<"Bob\n"; else if(N<=5) cout<<"Alice\n"; else if(N&1) cout<<"Alice\n"; else{ ll x=0; for(ll t=61;t>=0;t--){ if(N&(1LL<<t)){ x=(1LL<<t); break; } } if(x==N) cout<<"Alice\n"; else cout<<"Bob\n"; } } } }