結果

問題 No.38 赤青白ブロック
ユーザー kohei2019kohei2019
提出日時 2021-02-18 15:12:59
言語 PyPy3
(7.3.13)
結果
WA  
実行時間 -
コード長 942 bytes
コンパイル時間 306 ms
コンパイル使用メモリ 87,016 KB
実行使用メモリ 78,636 KB
最終ジャッジ日時 2023-10-12 23:26:38
合計ジャッジ時間 27,332 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 905 ms
77,924 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 968 ms
78,248 KB
testcase_04 AC 867 ms
77,820 KB
testcase_05 AC 985 ms
77,844 KB
testcase_06 WA -
testcase_07 AC 851 ms
78,252 KB
testcase_08 AC 944 ms
77,544 KB
testcase_09 WA -
testcase_10 AC 918 ms
77,756 KB
testcase_11 AC 1,141 ms
77,856 KB
testcase_12 AC 851 ms
78,092 KB
testcase_13 AC 953 ms
77,784 KB
testcase_14 AC 825 ms
78,024 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 865 ms
78,088 KB
testcase_20 AC 920 ms
78,636 KB
testcase_21 AC 826 ms
78,460 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 872 ms
78,060 KB
testcase_26 AC 831 ms
78,244 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[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