結果

問題 No.38 赤青白ブロック
ユーザー dearorange31dearorange31
提出日時 2017-09-09 16:09:25
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,188 bytes
コンパイル時間 1,098 ms
コンパイル使用メモリ 68,444 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-25 00:17:55
合計ジャッジ時間 2,319 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 20 ms
5,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 20 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 WA -
testcase_16 AC 3 ms
5,376 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 16 ms
5,376 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<map>

using namespace std;

int main(){
	int kr,kb;
	cin >> kr >> kb;
	
	string s;
	cin >> s;
	
	map<int,int> mp;
	
	int ind = 0;
	for(int i = 0;i < s.size();i++){
		if(s[i] != 'W'){
			mp[i] = ind;
			ind++;
		}
	}
	
	int bi = -1;
	for(int i = ((1 << 20) - 1);i >= 0;i--){
		string tests = "";
		for(int j = 0;j < s.size();j++){
			if(s[j] == 'W'){
				tests += s.substr(j,1);
			}else{
				if((i >> mp[j]) % 2 == 1){
					tests += s.substr(j,1);
				}
			}
		}
		
		bool ok = true;
		for(int j = 0;j < tests.size();j++){
			if(tests[j] == 'B'){
				if(j >= kb){
					if(tests[j - kb] == 'B' || tests[j + kb] == 'B'){
						ok = false;
						break;
					}
				}else{
					if(tests[j + kb] == 'B'){
						ok = false;
						break;
					}
				}
			}else if(tests[j] == 'R'){
				if(j >= kr){
					if(tests[j - kr] == 'R' || tests[j + kr] == 'R'){
						ok = false;
						break;
					}
				}else{
					if(tests[j + kr] == 'R'){
						ok = false;
						break;
					}
				}
			}
		}
		
		if(ok){
			bi = i;
			break;
		}
	}
	
	int ans = 10;
	for(int i = 0;i < 20;i++){
		if((bi >> i) % 2 == 1){
			ans++;
		}
	}
	
	cout << ans << endl;
	return 0;
}
0