結果

問題 No.38 赤青白ブロック
ユーザー kyuridenamidakyuridenamida
提出日時 2016-02-11 11:19:41
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 320 ms / 5,000 ms
コード長 1,052 bytes
コンパイル時間 1,403 ms
コンパイル使用メモリ 149,356 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-25 01:12:55
合計ジャッジ時間 10,592 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 262 ms
4,504 KB
testcase_01 AC 300 ms
4,380 KB
testcase_02 AC 298 ms
4,376 KB
testcase_03 AC 301 ms
4,380 KB
testcase_04 AC 303 ms
4,376 KB
testcase_05 AC 273 ms
4,380 KB
testcase_06 AC 309 ms
4,380 KB
testcase_07 AC 320 ms
4,380 KB
testcase_08 AC 273 ms
4,376 KB
testcase_09 AC 285 ms
4,380 KB
testcase_10 AC 273 ms
4,376 KB
testcase_11 AC 269 ms
4,376 KB
testcase_12 AC 288 ms
4,380 KB
testcase_13 AC 267 ms
4,376 KB
testcase_14 AC 301 ms
4,376 KB
testcase_15 AC 277 ms
4,376 KB
testcase_16 AC 301 ms
4,376 KB
testcase_17 AC 303 ms
4,380 KB
testcase_18 AC 275 ms
4,376 KB
testcase_19 AC 273 ms
4,380 KB
testcase_20 AC 299 ms
4,376 KB
testcase_21 AC 313 ms
4,380 KB
testcase_22 AC 274 ms
4,376 KB
testcase_23 AC 266 ms
4,380 KB
testcase_24 AC 318 ms
4,380 KB
testcase_25 AC 292 ms
4,376 KB
testcase_26 AC 290 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0 ; (i) < (int)(n) ; (i)++)
#define REP(i,a,b) for(int (i) = a ; (int)(i) <= (int)(b) ; (i)++)
#define all(n) (n).begin(),(n).end()
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<long long,long long> Pii;
typedef vector<Pii> VPii;


int main(){
	int Kr,Kb;
	string S;
	cin >> Kr >> Kb;
	cin >> S;
	Vi p;
	int ans = 0;
	for(int i = 0 ; i < S.size() ; i++) if( S[i] != 'W' ) p.push_back(i);
	for(int i = 0 ; i < (1<<p.size()) ; i++){
		string T = S;
		for(int j = 0 ; j < p.size() ; j++){
			if( i >> j & 1 ) T[p[j]] = '#';
		}
		T.erase(remove(T.begin(),T.end(),'#'),T.end());
		int ok = 1;
		for(int j = 0 ; j < T.size() ; j++){
			if( j - Kr >= 0 && T[j-Kr] == 'R' && T[j] == 'R' ) ok = 0; 
			if( j - Kb >= 0 && T[j-Kb] == 'B' && T[j] == 'B' ) ok = 0; 
			if( j + Kr < T.size() && T[j+Kr] == 'R' && T[j] == 'R' ) ok = 0; 
			if( j + Kb < T.size() && T[j+Kb] == 'B' && T[j] == 'B' ) ok = 0; 
		}
		if(ok)ans = max(ans,(int)T.size());
	}
	cout << ans << endl;
}
0