結果
問題 |
No.2278 Time Bomb Game 2
|
ユーザー |
|
提出日時 | 2025-01-26 00:39:22 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 704 bytes |
コンパイル時間 | 698 ms |
コンパイル使用メモリ | 65,024 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2025-01-26 00:39:25 |
合計ジャッジ時間 | 2,859 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 70 |
ソースコード
#include<iostream> #include<algorithm> #include<cassert> using namespace std; int N,K,T; bool solve(string C,int K,int T) { bool win=false; bool fn=false; for(int t=0;t<2;t++) { int l=K; while(l>=0&&C[K]==C[l])l--; if(l>=0&&(K-l)%2==T%2&&K-l<=T)win=true; reverse(C.begin(),C.end()); K=N-1-K; if(K-l>=2)fn=true; } if(fn)return win^(C[K]=='B'); else return C[K]=='B'; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin>>N>>K>>T; string C;cin>>C; K--; bool win; if(T%2==0)win=solve(C,K,T); else { int ex=0; if(K>0)ex|=1<<solve(C,K-1,T-1); if(K+1<N)ex|=1<<solve(C,K+1,T-1); if(C[K]=='A')win=ex&2; else win=!(ex&1); } cout<<(!win?"Bob":"Alice")<<endl; }