結果
問題 |
No.2278 Time Bomb Game 2
|
ユーザー |
|
提出日時 | 2025-02-21 20:56:54 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 5 ms / 2,000 ms |
コード長 | 837 bytes |
コンパイル時間 | 3,878 ms |
コンパイル使用メモリ | 276,820 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2025-02-21 20:57:01 |
合計ジャッジ時間 | 7,091 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 70 |
ソースコード
#include<bits/stdc++.h> using namespace std; #define rep(i,a,b) for(int i=(a);i<(b);i++) #define all(a) begin(a),end(a) #define sz(a) (int)(a).size() typedef long long ll; typedef vector<int> vi; typedef pair<int,int> pii; bool f(int N,int K,int T,string S){ if(S[K]=='B'){ rep(i,0,N)S[i]='A'+'B'-S[i]; return !f(N,K,T,S); } int l=K,r=K; while(l>=0&&S[l]=='A')l--; while(r<N&&S[r]=='A')r++; if(r-l==2&&T%2==0)return false; if(r-l==2&&T%2==1){ if(K&&f(N,K-1,T-1,S))return true; if(K+1<N&&f(N,K+1,T-1,S))return true; return false; } if(l>=0&&K-l<=T&&(T+K+l)%2==0)return true; if(r<N&&r-K<=T&&(T+K+r)%2==0)return true; return false; } int main(){ cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); int N,K,T;cin>>N>>K>>T;K--; string S;cin>>S; if(f(N,K,T,S))cout<<"Alice"<<endl; else cout<<"Bob"<<endl; }