結果

問題 No.38 赤青白ブロック
ユーザー antaanta
提出日時 2015-09-26 15:06:31
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 211 ms / 5,000 ms
コード長 1,253 bytes
コンパイル時間 1,103 ms
コンパイル使用メモリ 75,916 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-25 01:09:22
合計ジャッジ時間 7,125 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 200 ms
4,380 KB
testcase_01 AC 179 ms
4,380 KB
testcase_02 AC 188 ms
4,380 KB
testcase_03 AC 186 ms
4,380 KB
testcase_04 AC 196 ms
4,380 KB
testcase_05 AC 194 ms
4,380 KB
testcase_06 AC 190 ms
4,376 KB
testcase_07 AC 201 ms
4,380 KB
testcase_08 AC 187 ms
4,376 KB
testcase_09 AC 199 ms
4,376 KB
testcase_10 AC 185 ms
4,380 KB
testcase_11 AC 191 ms
4,380 KB
testcase_12 AC 211 ms
4,384 KB
testcase_13 AC 197 ms
4,380 KB
testcase_14 AC 194 ms
4,380 KB
testcase_15 AC 205 ms
4,376 KB
testcase_16 AC 183 ms
4,380 KB
testcase_17 AC 190 ms
4,376 KB
testcase_18 AC 188 ms
4,376 KB
testcase_19 AC 188 ms
4,376 KB
testcase_20 AC 203 ms
4,376 KB
testcase_21 AC 186 ms
4,380 KB
testcase_22 AC 192 ms
4,380 KB
testcase_23 AC 197 ms
4,380 KB
testcase_24 AC 189 ms
4,376 KB
testcase_25 AC 208 ms
4,380 KB
testcase_26 AC 196 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	int Kr;
	int Kb;
	while(~scanf("%d%d", &Kr, &Kb)) {
		const int K = 10, L = K * 3, M = K * 2;
		char S[L + 1];
		scanf("%s", S);
		string s;
		int ans = 0;
		for(int i = 0; i < 1 << M; ++ i) {
			s.clear();
			int k = 0;
			for(int j = 0; j < L; ++ j) {
				if(S[j] == 'W' || (i >> k ++ & 1))
					s += S[j];
			}
			int n = s.size();
			bool ok = true;
			for(int j = 0; j < n; ++ j) {
				if(s[j] != 'W') {
					int t = s[j] == 'R' ? Kr : Kb;
					if(j + t < n)
						ok &= s[j + t] != s[j];
				}
			}
			if(ok)
				amax(ans, n);
		}
		printf("%d\n", ans);
	}
	return 0;
}
0