結果

問題 No.38 赤青白ブロック
ユーザー beetbeet
提出日時 2019-02-22 21:16:33
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 445 ms / 5,000 ms
コード長 1,163 bytes
コンパイル時間 2,337 ms
コンパイル使用メモリ 202,084 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-16 15:04:59
合計ジャッジ時間 15,476 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 426 ms
4,380 KB
testcase_01 AC 413 ms
4,380 KB
testcase_02 AC 421 ms
4,380 KB
testcase_03 AC 425 ms
4,384 KB
testcase_04 AC 421 ms
4,376 KB
testcase_05 AC 425 ms
4,380 KB
testcase_06 AC 422 ms
4,380 KB
testcase_07 AC 412 ms
4,380 KB
testcase_08 AC 418 ms
4,384 KB
testcase_09 AC 431 ms
4,376 KB
testcase_10 AC 430 ms
4,380 KB
testcase_11 AC 432 ms
4,380 KB
testcase_12 AC 437 ms
4,380 KB
testcase_13 AC 430 ms
4,376 KB
testcase_14 AC 424 ms
4,380 KB
testcase_15 AC 419 ms
4,380 KB
testcase_16 AC 429 ms
4,380 KB
testcase_17 AC 418 ms
4,384 KB
testcase_18 AC 424 ms
4,380 KB
testcase_19 AC 410 ms
4,376 KB
testcase_20 AC 430 ms
4,376 KB
testcase_21 AC 414 ms
4,380 KB
testcase_22 AC 409 ms
4,376 KB
testcase_23 AC 427 ms
4,380 KB
testcase_24 AC 424 ms
4,380 KB
testcase_25 AC 445 ms
4,376 KB
testcase_26 AC 408 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  int p,q;
  cin>>p>>q;
  string s;
  cin>>s;
  vector<int> rs(10),bs(10);
  for(int i=0,r=0,b=0;i<30;i++){
    if(s[i]=='R') rs[r++]=i;
    if(s[i]=='B') bs[b++]=i;
  }
  int ans=0;
  for(int r=0;r<(1<<10);r++){
    for(int b=0;b<(1<<10);b++){
      vector<int> used(30,0);
      for(int i=0,j=0;i<30;i++){
        if(s[i]!='R') continue;
        if((r>>j)&1) used[rs[j]]=1;
        j++;
      }
      for(int i=0,j=0;i<30;i++){
        if(s[i]!='B') continue;
        if((b>>j)&1) used[bs[j]]=1;
        j++;
      }
      for(int i=0;i<30;i++)
        if(s[i]=='W') used[i]=1;
      
      string t;
      for(int i=0;i<30;i++)
        if(used[i]) t+=s[i];

      int m=t.size();
      int flg=1;
      for(int i=0;i<m;i++){
        if(t[i]=='R'&&i>=p&&t[i-p]=='R') flg=0;
        if(t[i]=='B'&&i>=q&&t[i-q]=='B') flg=0;
      }
      if(flg) chmax(ans,m);
    }
  }
  cout<<ans<<endl;
  return 0;
}
0