結果

問題 No.2278 Time Bomb Game 2
ユーザー otoshigo
提出日時 2023-04-21 22:17:48
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,486 bytes
コンパイル時間 708 ms
コンパイル使用メモリ 74,276 KB
最終ジャッジ日時 2025-02-12 11:53:26
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 68 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}
template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}

bool F(char c,bool flag,int n,int k,int t,string&s){
    int l=k,r=k;
    while(l>=0&&s[l]==c)l--;
    l++;
    while(r<n&&s[r]==c)r++;
    r--;
    if(l==r){
        if(t%2==0)return false;
        else{
            if(flag){
                bool f=false;
                if(k-1>=0)f=f||!F(char('A'+'B'-c),!flag,n,k-1,t-1,s);
                if(k+1<n)f=f||!F(char('A'+'B'-c),!flag,n,k+1,t-1,s);
                return f;
            }
            else{
                return false;
            }
        }
    }else{
        if(min(k-l,r-k)>=t)return false;
        else if((t%2==1&&((l!=0&&k%2==l%2)||(r!=n-1&&k%2==r%2)))||(t%2==0&&((l!=0&&k%2!=l%2)||(r!=n-1&&k%2!=r%2))))return true;
        else return false;
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,k,t;
    cin>>n>>k>>t;
    k--;
    string s;
    cin>>s;
    if(F(s[k],true,n,k,t,s)){
        if(s[k]=='A')cout<<"Alice"<<"\n";
        else cout<<"Bob"<<"\n";
    }else{
        if(s[k]=='B')cout<<"Alice"<<"\n";
        else cout<<"Bob"<<"\n";
    }
}
0