結果

問題 No.38 赤青白ブロック
ユーザー nebukuro09nebukuro09
提出日時 2016-10-17 15:54:46
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 886 ms / 5,000 ms
コード長 576 bytes
コンパイル時間 150 ms
コンパイル使用メモリ 77,884 KB
実行使用メモリ 79,952 KB
最終ジャッジ日時 2023-08-25 01:20:46
合計ジャッジ時間 23,896 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 810 ms
79,628 KB
testcase_01 AC 822 ms
79,736 KB
testcase_02 AC 772 ms
79,620 KB
testcase_03 AC 815 ms
79,736 KB
testcase_04 AC 785 ms
79,644 KB
testcase_05 AC 761 ms
79,572 KB
testcase_06 AC 879 ms
79,952 KB
testcase_07 AC 886 ms
79,612 KB
testcase_08 AC 719 ms
79,460 KB
testcase_09 AC 839 ms
79,568 KB
testcase_10 AC 737 ms
79,384 KB
testcase_11 AC 747 ms
79,604 KB
testcase_12 AC 766 ms
79,620 KB
testcase_13 AC 770 ms
79,624 KB
testcase_14 AC 780 ms
79,612 KB
testcase_15 AC 816 ms
79,796 KB
testcase_16 AC 776 ms
79,524 KB
testcase_17 AC 800 ms
79,860 KB
testcase_18 AC 860 ms
79,860 KB
testcase_19 AC 827 ms
79,600 KB
testcase_20 AC 802 ms
79,832 KB
testcase_21 AC 860 ms
79,904 KB
testcase_22 AC 758 ms
79,904 KB
testcase_23 AC 759 ms
79,324 KB
testcase_24 AC 836 ms
79,708 KB
testcase_25 AC 785 ms
79,708 KB
testcase_26 AC 823 ms
79,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

Kr, Kb = map(int, raw_input().split())
S = raw_input()
C = S.count('R') + S.count('B')

def solve(b):
    newS = ''
    c = -1
    for i, s in enumerate(S):
        if s != 'W':
            c += 1
            if ((1<<c) & b):
                continue
        newS += s
    N = len(newS)
    for i in xrange(N-Kr):
        if newS[i] == 'R' and newS[i+Kr] == 'R':
            return 0
    for i in xrange(N-Kb):
        if newS[i] == 'B' and newS[i+Kb] == 'B':
            return 0
    return N

ans = S.count('W')
for b in xrange(1<<C):
    ans = max(solve(b), ans)
print ans
0