結果

問題 No.38 赤青白ブロック
ユーザー ttkkggwwttkkggww
提出日時 2022-04-01 11:45:13
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 241 ms / 5,000 ms
コード長 800 bytes
コンパイル時間 4,810 ms
コンパイル使用メモリ 259,688 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-12 04:37:55
合計ジャッジ時間 12,564 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 212 ms
4,380 KB
testcase_01 AC 202 ms
4,384 KB
testcase_02 AC 206 ms
4,380 KB
testcase_03 AC 201 ms
4,384 KB
testcase_04 AC 210 ms
4,380 KB
testcase_05 AC 209 ms
4,380 KB
testcase_06 AC 222 ms
4,384 KB
testcase_07 AC 214 ms
4,380 KB
testcase_08 AC 195 ms
4,384 KB
testcase_09 AC 219 ms
4,380 KB
testcase_10 AC 197 ms
4,384 KB
testcase_11 AC 200 ms
4,380 KB
testcase_12 AC 221 ms
4,380 KB
testcase_13 AC 211 ms
4,384 KB
testcase_14 AC 221 ms
4,380 KB
testcase_15 AC 221 ms
4,384 KB
testcase_16 AC 203 ms
4,380 KB
testcase_17 AC 215 ms
4,380 KB
testcase_18 AC 205 ms
4,384 KB
testcase_19 AC 207 ms
4,384 KB
testcase_20 AC 228 ms
4,380 KB
testcase_21 AC 209 ms
4,380 KB
testcase_22 AC 238 ms
4,380 KB
testcase_23 AC 216 ms
4,380 KB
testcase_24 AC 216 ms
4,380 KB
testcase_25 AC 241 ms
4,380 KB
testcase_26 AC 223 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#include<atcoder/all>
using namespace atcoder;
using ll = long long;
int r,b;
string s;

void solve(){
	int ans  =0;
	for(int bit = 0;bit<(1<<20);bit++){
		string t;
		int j = 0;
		for(int i =0;i<30;i++){
			if(s[i]=='W'){
				t.push_back('W');
			}else{
				if((bit>>j)&1){
					t.push_back(s[i]);
				}
				j++;
			}
		}
		bool is = true;
		for(int i  =0;i<t.size();i++){
			if(t[i]=='W')continue;
			int L = i - (t[i]=='R'?r:b),R = i + (t[i]=='R'?r:b);
			if(L>=0&&L<(int)t.size()){
				if(t[i]==t[L])is = false;
			}
			if(R>=0&&R<(int)t.size()){
				if(t[i]==t[R])is = false;
			}
		}
		if(is)ans = max(ans,(int)t.size());
	}
	cout<<ans<<endl;
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cin >> r >> b;
	cin >> s;
	solve();
}
0