結果

問題 No.38 赤青白ブロック
ユーザー kohei2019kohei2019
提出日時 2021-02-18 15:21:10
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 1,190 ms / 5,000 ms
コード長 948 bytes
コンパイル時間 295 ms
コンパイル使用メモリ 87,204 KB
実行使用メモリ 78,828 KB
最終ジャッジ日時 2023-10-12 23:32:59
合計ジャッジ時間 28,782 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 963 ms
77,772 KB
testcase_01 AC 922 ms
78,428 KB
testcase_02 AC 835 ms
77,936 KB
testcase_03 AC 954 ms
77,892 KB
testcase_04 AC 1,025 ms
78,412 KB
testcase_05 AC 1,012 ms
77,800 KB
testcase_06 AC 890 ms
78,828 KB
testcase_07 AC 937 ms
78,444 KB
testcase_08 AC 987 ms
77,784 KB
testcase_09 AC 931 ms
78,520 KB
testcase_10 AC 951 ms
77,776 KB
testcase_11 AC 1,190 ms
77,908 KB
testcase_12 AC 885 ms
77,812 KB
testcase_13 AC 1,012 ms
78,132 KB
testcase_14 AC 909 ms
77,828 KB
testcase_15 AC 946 ms
78,188 KB
testcase_16 AC 891 ms
78,184 KB
testcase_17 AC 885 ms
78,176 KB
testcase_18 AC 1,028 ms
78,328 KB
testcase_19 AC 968 ms
78,360 KB
testcase_20 AC 972 ms
78,720 KB
testcase_21 AC 856 ms
78,304 KB
testcase_22 AC 931 ms
77,844 KB
testcase_23 AC 957 ms
78,040 KB
testcase_24 AC 939 ms
78,380 KB
testcase_25 AC 922 ms
78,060 KB
testcase_26 AC 920 ms
78,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import copy
Kr,Kb = map(int,input().split())
S = list(input())

lsBR = []
for i in range(len(S)):
    if S[i] == 'B' or S[i] == 'R':
        lsBR.append(i)
ans = 0
for i in range(2**len(lsBR)):
    S1 = copy.copy(S)
    for j in range(len(lsBR)):
        if (i>>j) & 1:
            S1[lsBR[j]] = ''
    S2 = ''.join(S1)
    f = True
    for j in range(len(S2)):
        if S2[j] == 'R':
            if j-Kr >= 0:
                if S2[j-Kr] == 'R':
                    f = False
                    break
            if j+Kr < len(S2):
                if S2[j+Kr] == 'R':
                    f = False
                    break
        elif S2[j] == 'B':
            if j-Kb >= 0:
                if S2[j-Kb] == 'B':
                    f = False
                    break
            if j+Kb < len(S2):
                if S2[j+Kb] == 'B':
                    f = False
                    break
    if f:
        ans = max(len(S2),ans)
print(ans)
0