結果

問題 No.2278 Time Bomb Game 2
ユーザー otoshigootoshigo
提出日時 2023-04-21 22:30:05
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,463 bytes
コンパイル時間 775 ms
コンパイル使用メモリ 76,104 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-06 17:05:37
合計ジャッジ時間 2,715 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 70
権限があれば一括ダウンロードができます

ソースコード

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,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{
            bool f=false;
            if(k-1>=0)f=f||!F(char('A'+'B'-c),n,k-1,t-1,s);
            if(k+1<n)f=f||!F(char('A'+'B'-c),n,k+1,t-1,s);
            return f;
        }
    }else{
        if(min(k-l,r-k)>=t)return false;
        else if((t%2==1&&((l!=0&&k-l<t&&k%2==l%2)||(r!=n-1&&r-k<t&&k%2==r%2)))||(t%2==0&&((l!=0&&k-l<t&&k%2!=l%2)||(r!=n-1&&r-k<t&&k%2!=r%2))))return true;
        else return false;
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int q;
    q=1;
    while(q--){
        int n,k,t;
        cin>>n>>k>>t;
        k--;
        string s;
        cin>>s;
        if(F(s[k],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