結果

問題 No.38 赤青白ブロック
ユーザー bal4ubal4u
提出日時 2019-06-30 22:07:02
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 122 ms / 5,000 ms
コード長 685 bytes
コンパイル時間 746 ms
コンパイル使用メモリ 28,284 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-21 03:14:52
合計ジャッジ時間 4,534 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
4,376 KB
testcase_01 AC 80 ms
4,376 KB
testcase_02 AC 90 ms
4,376 KB
testcase_03 AC 99 ms
4,380 KB
testcase_04 AC 68 ms
4,380 KB
testcase_05 AC 117 ms
4,380 KB
testcase_06 AC 69 ms
4,384 KB
testcase_07 AC 74 ms
4,380 KB
testcase_08 AC 116 ms
4,376 KB
testcase_09 AC 79 ms
4,376 KB
testcase_10 AC 116 ms
4,380 KB
testcase_11 AC 119 ms
4,376 KB
testcase_12 AC 103 ms
4,380 KB
testcase_13 AC 122 ms
4,380 KB
testcase_14 AC 91 ms
4,376 KB
testcase_15 AC 118 ms
4,376 KB
testcase_16 AC 51 ms
4,380 KB
testcase_17 AC 94 ms
4,380 KB
testcase_18 AC 117 ms
4,376 KB
testcase_19 AC 104 ms
4,376 KB
testcase_20 AC 85 ms
4,380 KB
testcase_21 AC 92 ms
4,376 KB
testcase_22 AC 94 ms
4,376 KB
testcase_23 AC 114 ms
4,376 KB
testcase_24 AC 64 ms
4,376 KB
testcase_25 AC 105 ms
4,380 KB
testcase_26 AC 106 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// yukicoder: No.38 赤青白ブロック
// 2019.6.30 bal4u

#include <stdio.h>

#define ST 35
#define LIM (1<<20)
int kr, kb;
char S[32], s[70];

int main()
{
	int i, j, w, ans;
	char *p, *q;
	
	scanf("%d%d", &kr, &kb);
	scanf("%s", S);
	
	ans = 0;
	i = LIM; while (i--) {
		j = i, p = S, q = s + ST, w = 0;
		while (*p) {
			while (*p == 'W') *q++ = 'W', w++, p++;
			if (*p == 'R') {
				if (j & 1) {
					if (*(q-kr) == 'R') goto done;
					*q++ = 'R';
				}
			} else {
				if (j & 1) {
					if (*(q-kb) == 'B') goto done;
					*q++ = 'B';
				}
			}
			if (!(j >>= 1)) break;
			p++;
		}
		q += 10 - w;
		if (q-s > ans) ans = q-s;
done:;
	}
	printf("%d\n", ans-ST);
	return 0;
}
0