結果

問題 No.38 赤青白ブロック
ユーザー lloyzlloyz
提出日時 2023-11-06 01:17:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,674 ms / 5,000 ms
コード長 888 bytes
コンパイル時間 383 ms
コンパイル使用メモリ 81,852 KB
実行使用メモリ 76,268 KB
最終ジャッジ日時 2023-11-06 01:17:29
合計ジャッジ時間 27,512 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 854 ms
75,836 KB
testcase_01 AC 781 ms
76,036 KB
testcase_02 AC 760 ms
76,036 KB
testcase_03 AC 855 ms
76,120 KB
testcase_04 AC 848 ms
76,236 KB
testcase_05 AC 872 ms
76,072 KB
testcase_06 AC 761 ms
76,240 KB
testcase_07 AC 804 ms
76,176 KB
testcase_08 AC 867 ms
76,152 KB
testcase_09 AC 827 ms
76,064 KB
testcase_10 AC 933 ms
76,192 KB
testcase_11 AC 885 ms
76,036 KB
testcase_12 AC 796 ms
76,036 KB
testcase_13 AC 884 ms
76,036 KB
testcase_14 AC 807 ms
76,268 KB
testcase_15 AC 835 ms
75,856 KB
testcase_16 AC 777 ms
76,036 KB
testcase_17 AC 772 ms
76,200 KB
testcase_18 AC 907 ms
76,248 KB
testcase_19 AC 830 ms
76,036 KB
testcase_20 AC 870 ms
76,268 KB
testcase_21 AC 758 ms
76,180 KB
testcase_22 AC 869 ms
76,036 KB
testcase_23 AC 917 ms
76,128 KB
testcase_24 AC 910 ms
76,032 KB
testcase_25 AC 1,674 ms
76,112 KB
testcase_26 AC 1,638 ms
76,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

def check(L):
    m = len(L)
    for i in range(m):
        if L[i] == 0:
            ni = i + r
            if ni < m:
                if L[ni] == 0:
                    return False
        elif L[i] == 1:
            ni = i + b
            if ni < m:
                if L[ni] == 1:
                    return False
    return True

ans = 0
for rbit in range(1 << 10):
    for bbit in range(1 << 10):
        L = []
        ri, bi = 0, 0
        for i in range(30):
            if S[i] == 'R':
                if (rbit >> ri) & 1:
                    L.append(0)
                ri += 1
            elif S[i] == 'B':
                if (bbit >> bi) & 1:
                    L.append(1)
                bi += 1
            else:
                L.append(2)
        if check(L):
            ans = max(ans, len(L))
print(ans)
0