結果

問題 No.2278 Time Bomb Game 2
ユーザー cho435cho435
提出日時 2023-04-21 23:31:52
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,513 bytes
コンパイル時間 2,377 ms
コンパイル使用メモリ 203,884 KB
実行使用メモリ 818,176 KB
最終ジャッジ日時 2024-04-24 09:27:25
合計ジャッジ時間 4,648 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 3 ms
5,376 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 4 ms
5,376 KB
testcase_07 AC 6 ms
5,376 KB
testcase_08 MLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
testcase_67 -- -
testcase_68 -- -
testcase_69 -- -
testcase_70 -- -
testcase_71 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i=0;i<(int)(n);i++)

int n;
string s;
vector<int> sl(2e5,-1);
vector<int> sr(2e5,-1);
int dfs(int nk,int nt){
  if(nt==0) return 0;
  int sz=sr.at(nk)-sl.at(nk);
  if(sz<=nt&&sz%2==0) return 1;
  if(sz==1){
    int rt=0;
    int enflg=1;
    if(nk>0){
      if(sr.at(nk-1)-sl.at(nk-1)!=1) enflg=0;
    }
    if(nk<n-1){
      if(sr.at(nk+1)-sl.at(nk+1)!=1) enflg=0;
    }
    if(enflg&&nt%2==0) return 0;
    if(nk>0){
      rt|=1^dfs(nk-1,nt-1);
    }
    if(nk<n-1){
      rt|=1^dfs(nk+1,nt-1);
    }
    return rt;
  }
  int rt=0;
  if(sl.at(nk)!=0){
    int df=nt-(nk-sl.at(nk));
    if(df>0){
      df=(df+1)%2;
      rt|=1^dfs(sl.at(nk)-1,df);
    }
  }
  if(sr.at(nk)!=n){
    int df=nt-(sr.at(nk)-nk-1);
    if(df>0){
      df=(df+1)%2;
      rt|=1^dfs(sr.at(nk),df);
    }
  }
  return rt;
}

int main(){
  int k,t;
  cin>>n>>k>>t;
  k--;
  string s;
  cin>>s;
  {
    sl.at(0)=0;
    rep(i,n-1){
      if(s.at(i)==s.at(i+1)){
        sl.at(i+1)=sl.at(i);
      }else{
        sl.at(i+1)=i+1;
      }
    }
    reverse(s.begin(),s.end());
    sr.at(0)=n;
    rep(i,n-1){
      if(s.at(i)==s.at(i+1)){
        sr.at(i+1)=sr.at(i);
      }else{
        sr.at(i+1)=n-i-1;
      }
    }
    reverse(s.begin(),s.end());
    reverse(sr.begin(),sr.begin()+n);
  }
  map<char,string> mp={{'A',"Alice"},{'B',"Bob"}};
  char rv='A'^'B'^s.at(k);
  if(dfs(k,t)) cout<<mp.at(s.at(k))<<endl;
  else cout<<mp.at(rv)<<endl;
}
0