結果

問題 No.38 赤青白ブロック
ユーザー furafura
提出日時 2020-06-07 13:36:25
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 207 ms / 5,000 ms
コード長 659 bytes
コンパイル時間 1,965 ms
コンパイル使用メモリ 201,312 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-25 10:38:10
合計ジャッジ時間 8,842 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 182 ms
4,376 KB
testcase_01 AC 190 ms
4,376 KB
testcase_02 AC 180 ms
4,376 KB
testcase_03 AC 200 ms
4,380 KB
testcase_04 AC 200 ms
4,380 KB
testcase_05 AC 174 ms
4,376 KB
testcase_06 AC 200 ms
4,380 KB
testcase_07 AC 186 ms
4,376 KB
testcase_08 AC 173 ms
4,380 KB
testcase_09 AC 207 ms
4,376 KB
testcase_10 AC 176 ms
4,376 KB
testcase_11 AC 174 ms
4,376 KB
testcase_12 AC 190 ms
4,376 KB
testcase_13 AC 176 ms
4,380 KB
testcase_14 AC 191 ms
4,380 KB
testcase_15 AC 172 ms
4,376 KB
testcase_16 AC 187 ms
4,380 KB
testcase_17 AC 177 ms
4,380 KB
testcase_18 AC 183 ms
4,380 KB
testcase_19 AC 173 ms
4,380 KB
testcase_20 AC 200 ms
4,376 KB
testcase_21 AC 188 ms
4,380 KB
testcase_22 AC 177 ms
4,376 KB
testcase_23 AC 183 ms
4,376 KB
testcase_24 AC 198 ms
4,376 KB
testcase_25 AC 187 ms
4,376 KB
testcase_26 AC 177 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int kr,kb;
	string s; cin>>kr>>kb>>s;

	vector<int> r,b;
	rep(i,30){
		if(s[i]=='R') r.emplace_back(i);
		if(s[i]=='B') b.emplace_back(i);
	}

	int ans=0;
	rep(R,1<<10) rep(B,1<<10) {
		bool del[30]={};
		rep(i,10){
			if(R>>i&1) del[r[i]]=true;
			if(B>>i&1) del[b[i]]=true;
		}

		int len=0;
		char t[31]={};
		rep(i,30) if(!del[i]) t[len++]=s[i];

		bool ok=true;
		rep(i,len){
			if(i+kr<len && t[i]=='R' && t[i+kr]=='R') ok=false;
			if(i+kb<len && t[i]=='B' && t[i+kb]=='B') ok=false;
		}
		if(ok) ans=max(ans,len);
	}
	cout<<ans<<'\n';

	return 0;
}
0