結果

問題 No.38 赤青白ブロック
ユーザー rlangevinrlangevin
提出日時 2023-09-25 12:22:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 957 ms / 5,000 ms
コード長 1,060 bytes
コンパイル時間 374 ms
コンパイル使用メモリ 86,940 KB
実行使用メモリ 78,284 KB
最終ジャッジ日時 2023-09-25 12:22:47
合計ジャッジ時間 27,159 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 882 ms
76,988 KB
testcase_01 AC 903 ms
77,832 KB
testcase_02 AC 801 ms
77,744 KB
testcase_03 AC 916 ms
77,796 KB
testcase_04 AC 854 ms
77,840 KB
testcase_05 AC 914 ms
77,952 KB
testcase_06 AC 803 ms
77,716 KB
testcase_07 AC 871 ms
78,032 KB
testcase_08 AC 915 ms
77,768 KB
testcase_09 AC 837 ms
77,404 KB
testcase_10 AC 947 ms
77,580 KB
testcase_11 AC 906 ms
77,660 KB
testcase_12 AC 824 ms
77,388 KB
testcase_13 AC 859 ms
77,416 KB
testcase_14 AC 869 ms
77,508 KB
testcase_15 AC 881 ms
77,448 KB
testcase_16 AC 836 ms
77,652 KB
testcase_17 AC 810 ms
77,640 KB
testcase_18 AC 931 ms
77,568 KB
testcase_19 AC 855 ms
77,748 KB
testcase_20 AC 928 ms
78,256 KB
testcase_21 AC 798 ms
77,292 KB
testcase_22 AC 885 ms
77,636 KB
testcase_23 AC 957 ms
78,284 KB
testcase_24 AC 777 ms
77,624 KB
testcase_25 AC 888 ms
77,356 KB
testcase_26 AC 885 ms
77,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

Kr, Kb = map(int, input().split())
S = list(input())
M = 1 << 10
ans = 0

def check(A):
    for i in range(len(A)):
        if A[i] == 0:
            if i - Kr >= 0:
                if A[i - Kr] == 0:
                    return False
            if i + Kr <= len(A) - 1:
                if A[i + Kr] == 0:
                    return False
        if A[i] == 1:
            if i - Kb >= 0:
                if A[i - Kb] == 1:
                    return False
            if i + Kb <= len(A) - 1:
                if A[i + Kb] == 1:
                    return False
    return True


for sr in range(M):
    for sb in range(M):
        ir, ib = 0, 0
        temp = []
        for i in range(30):
            if S[i] == "R":
                if (sr >> ir) & 1:
                    temp.append(0)
                ir += 1
            elif S[i] == "B":
                if (sb >> ib) & 1:
                    temp.append(1)
                ib += 1
            else:
                temp.append(2)
        if check(temp):
            ans = max(ans, len(temp))

print(ans)
0