結果

問題 No.38 赤青白ブロック
ユーザー H3PO4H3PO4
提出日時 2020-04-21 14:24:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,069 ms / 5,000 ms
コード長 669 bytes
コンパイル時間 210 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 76,800 KB
最終ジャッジ日時 2024-04-16 23:34:27
合計ジャッジ時間 29,621 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,034 ms
76,160 KB
testcase_01 AC 973 ms
76,672 KB
testcase_02 AC 952 ms
76,544 KB
testcase_03 AC 1,043 ms
76,416 KB
testcase_04 AC 968 ms
76,544 KB
testcase_05 AC 1,069 ms
76,544 KB
testcase_06 AC 965 ms
76,288 KB
testcase_07 AC 961 ms
76,160 KB
testcase_08 AC 1,065 ms
76,160 KB
testcase_09 AC 980 ms
76,160 KB
testcase_10 AC 1,065 ms
76,032 KB
testcase_11 AC 1,023 ms
75,904 KB
testcase_12 AC 989 ms
75,904 KB
testcase_13 AC 1,033 ms
76,288 KB
testcase_14 AC 988 ms
76,288 KB
testcase_15 AC 1,017 ms
76,032 KB
testcase_16 AC 869 ms
76,160 KB
testcase_17 AC 949 ms
76,160 KB
testcase_18 AC 1,033 ms
76,800 KB
testcase_19 AC 1,016 ms
76,160 KB
testcase_20 AC 953 ms
76,288 KB
testcase_21 AC 923 ms
76,416 KB
testcase_22 AC 969 ms
76,288 KB
testcase_23 AC 1,069 ms
76,032 KB
testcase_24 AC 972 ms
76,544 KB
testcase_25 AC 992 ms
76,160 KB
testcase_26 AC 1,001 ms
76,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools

R, B = map(int, input().split())
S = input()
ans = 0
for t in itertools.product((0, 1), repeat=20):
    j = 0
    S_new = []
    for s in S:
        if s == 'W':
            S_new.append(s)
        else:
            if t[j]:
                S_new.append(s)
            j += 1
    l = len(S_new)
    for j in range(l):
        if S_new[j] == 'R':
            if (j - R >= 0 and S_new[j - R] == 'R') or (j + R < l and S_new[j + R] == 'R'):
                break
        elif S_new[j] == 'B':
            if (j - B >= 0 and S_new[j - B] == 'B') or (j + B < l and S_new[j + B] == 'B'):
                break
    else:
        ans = max(ans, l)
print(ans)
0