結果

問題 No.38 赤青白ブロック
ユーザー itezpaceitezpace
提出日時 2016-11-30 06:37:52
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 267 ms / 5,000 ms
コード長 946 bytes
コンパイル時間 766 ms
コンパイル使用メモリ 63,596 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-25 01:20:00
合計ジャッジ時間 8,488 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 256 ms
4,376 KB
testcase_01 AC 219 ms
4,376 KB
testcase_02 AC 223 ms
4,376 KB
testcase_03 AC 235 ms
4,380 KB
testcase_04 AC 226 ms
4,380 KB
testcase_05 AC 267 ms
4,380 KB
testcase_06 AC 223 ms
4,380 KB
testcase_07 AC 223 ms
4,380 KB
testcase_08 AC 265 ms
4,376 KB
testcase_09 AC 238 ms
4,380 KB
testcase_10 AC 257 ms
4,380 KB
testcase_11 AC 257 ms
4,380 KB
testcase_12 AC 234 ms
4,380 KB
testcase_13 AC 256 ms
4,380 KB
testcase_14 AC 242 ms
4,380 KB
testcase_15 AC 261 ms
4,380 KB
testcase_16 AC 206 ms
4,376 KB
testcase_17 AC 217 ms
4,376 KB
testcase_18 AC 254 ms
4,380 KB
testcase_19 AC 232 ms
4,376 KB
testcase_20 AC 232 ms
4,376 KB
testcase_21 AC 219 ms
4,376 KB
testcase_22 AC 247 ms
4,380 KB
testcase_23 AC 255 ms
4,376 KB
testcase_24 AC 227 ms
4,376 KB
testcase_25 AC 246 ms
4,376 KB
testcase_26 AC 230 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <bitset>
#include <vector>
using namespace  std;
int main(){
  int Kr,Kb; string S;
  cin>>Kr>>Kb;
  cin>>S;
  vector<int> v1;
  for(int i=0;i<S.size();++i){
    if(S[i]=='B' || S[i]=='R') v1.push_back(i);
  }
  int ans=0;
  for(int i=0;i<1048576;++i){
    bitset<20> bs1(i);
    string S2=S;
    int a=0;
    for(int j=0;j<20;++j){
      if(!bs1.test(j)){
        S2.erase(v1[j]-a,1);
        a+=1;
      }
    }
    bool check=true;
    for(int j=0;j<S2.size();++j){
      if(S2[j]=='R' && j+Kr<S2.size() && S2[j+Kr]=='R'){
        check=false;break;
      }
      if(S2[j]=='R' && j-Kr>=0 && S2[j-Kr]=='R'){
        check=false;break;
      }
      if(S2[j]=='B' && j+Kb<S2.size() && S2[j+Kb]=='B'){
        check=false;break;
      }
      if(S2[j]=='B' && j-Kb>=0 && S2[j-Kb]=='B'){
        check=false;break;
      }
    }
    if(check && ans<S2.size()) ans=S2.size();
  }
  cout<<ans<<endl;
}
0