結果

問題 No.38 赤青白ブロック
ユーザー 夜
提出日時 2021-02-04 23:39:52
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 275 ms / 5,000 ms
コード長 1,014 bytes
コンパイル時間 726 ms
コンパイル使用メモリ 93,500 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-13 20:11:21
合計ジャッジ時間 8,958 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 250 ms
4,376 KB
testcase_01 AC 232 ms
4,376 KB
testcase_02 AC 265 ms
4,376 KB
testcase_03 AC 233 ms
4,376 KB
testcase_04 AC 243 ms
4,376 KB
testcase_05 AC 240 ms
4,380 KB
testcase_06 AC 260 ms
4,376 KB
testcase_07 AC 262 ms
4,376 KB
testcase_08 AC 253 ms
4,380 KB
testcase_09 AC 254 ms
4,380 KB
testcase_10 AC 235 ms
4,376 KB
testcase_11 AC 244 ms
4,376 KB
testcase_12 AC 246 ms
4,376 KB
testcase_13 AC 241 ms
4,380 KB
testcase_14 AC 246 ms
4,376 KB
testcase_15 AC 275 ms
4,376 KB
testcase_16 AC 238 ms
4,380 KB
testcase_17 AC 242 ms
4,376 KB
testcase_18 AC 250 ms
4,380 KB
testcase_19 AC 250 ms
4,380 KB
testcase_20 AC 238 ms
4,376 KB
testcase_21 AC 263 ms
4,376 KB
testcase_22 AC 265 ms
4,380 KB
testcase_23 AC 225 ms
4,380 KB
testcase_24 AC 258 ms
4,380 KB
testcase_25 AC 249 ms
4,376 KB
testcase_26 AC 236 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int kr, kb;
	cin >> kr >> kb;
	string s;
	cin >> s;
	int ans = 0;
	for (int bit = 0; bit < (1 << 20); bit++) {
		int r = 0, b = 10;
		string s1 = "";
		for (int i = 0; i < 30; i++) {
			if (s[i] == 'R') {
				if (bit & (1 << r)) {
					s1 += 'R';
				}
				r++;
			}
			else if (s[i] == 'B') {
				if (bit & (1 << b)) {
					s1 += 'B';
				}
				b++;
			}
			else if (s[i] == 'W') {
				s1 += 'W';
			}
		}
		bool bo = true;
		for (int i = 0; i < s1.size(); i++) {
			if (s1[i] == 'R' && i - kr >= 0 && s1[i - kr] == 'R') {
				bo = false;
			}
			if (s1[i] == 'B' && i - kb >= 0 && s1[i - kb] == 'B') {
				bo = false;
			}
		}
		if (bo && ans < s1.size()) {
			ans = s1.size();
		}
	}
	cout << ans << endl;
}

0