結果

問題 No.38 赤青白ブロック
ユーザー 👑 rin204rin204
提出日時 2022-07-14 13:21:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 818 ms / 5,000 ms
コード長 653 bytes
コンパイル時間 757 ms
コンパイル使用メモリ 87,012 KB
実行使用メモリ 77,652 KB
最終ジャッジ日時 2023-09-08 03:22:02
合計ジャッジ時間 24,044 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 793 ms
77,324 KB
testcase_01 AC 778 ms
76,912 KB
testcase_02 AC 776 ms
77,264 KB
testcase_03 AC 788 ms
77,580 KB
testcase_04 AC 744 ms
76,952 KB
testcase_05 AC 780 ms
77,252 KB
testcase_06 AC 773 ms
77,136 KB
testcase_07 AC 791 ms
77,104 KB
testcase_08 AC 764 ms
77,028 KB
testcase_09 AC 794 ms
77,236 KB
testcase_10 AC 750 ms
76,776 KB
testcase_11 AC 750 ms
76,820 KB
testcase_12 AC 722 ms
77,000 KB
testcase_13 AC 753 ms
77,140 KB
testcase_14 AC 729 ms
77,192 KB
testcase_15 AC 757 ms
77,180 KB
testcase_16 AC 762 ms
76,936 KB
testcase_17 AC 753 ms
77,056 KB
testcase_18 AC 799 ms
77,652 KB
testcase_19 AC 750 ms
77,332 KB
testcase_20 AC 749 ms
77,344 KB
testcase_21 AC 722 ms
77,084 KB
testcase_22 AC 818 ms
77,196 KB
testcase_23 AC 735 ms
76,828 KB
testcase_24 AC 750 ms
77,068 KB
testcase_25 AC 793 ms
77,324 KB
testcase_26 AC 787 ms
77,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

r, b = map(int, input().split())
S = input()

ans = 0
for bit in range(1 << 20):
    p = 0
    T = []
    m = 30
    for s in S:
        if s == "W":
            T.append(s)
        else:
            if bit >> p & 1:
                T.append(s)
            else:
                m -= 1
            p += 1
    if m < ans:
        continue
    ok = True
    for i, t in enumerate(T):
        if t == "R":
            if i + r < m and T[i + r] == "R":
                ok = False
                break
        elif t == "B":
            if i + b < m and T[i + b] == "B":
                ok = False
                break
    if ok:
        ans = m
print(ans)
0