結果

問題 No.38 赤青白ブロック
ユーザー titiatitia
提出日時 2022-04-12 03:23:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 974 ms / 5,000 ms
コード長 529 bytes
コンパイル時間 544 ms
コンパイル使用メモリ 87,040 KB
実行使用メモリ 78,324 KB
最終ジャッジ日時 2023-08-22 08:52:08
合計ジャッジ時間 25,750 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 880 ms
77,376 KB
testcase_01 AC 974 ms
78,088 KB
testcase_02 AC 830 ms
77,100 KB
testcase_03 AC 928 ms
78,324 KB
testcase_04 AC 863 ms
77,844 KB
testcase_05 AC 816 ms
77,520 KB
testcase_06 AC 838 ms
78,084 KB
testcase_07 AC 853 ms
77,720 KB
testcase_08 AC 781 ms
77,296 KB
testcase_09 AC 865 ms
77,240 KB
testcase_10 AC 752 ms
77,408 KB
testcase_11 AC 775 ms
77,372 KB
testcase_12 AC 823 ms
77,360 KB
testcase_13 AC 786 ms
77,712 KB
testcase_14 AC 870 ms
77,796 KB
testcase_15 AC 851 ms
77,492 KB
testcase_16 AC 820 ms
77,736 KB
testcase_17 AC 833 ms
77,248 KB
testcase_18 AC 846 ms
77,564 KB
testcase_19 AC 872 ms
77,468 KB
testcase_20 AC 878 ms
77,448 KB
testcase_21 AC 835 ms
77,944 KB
testcase_22 AC 915 ms
77,372 KB
testcase_23 AC 819 ms
77,492 KB
testcase_24 AC 862 ms
77,796 KB
testcase_25 AC 844 ms
77,684 KB
testcase_26 AC 890 ms
77,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

def cond(A):
    for i in range(len(A)):
        if i+r<len(A) and A[i]==A[i+r]=="R":
            return False
        if i+b<len(A) and A[i]==A[i+b]=="B":
            return False
    return True

ANS=0
for i in range(1<<20):
    A=[]
    count=0
    for j in range(len(S)):
        if S[j]=="W":
            A.append("W")
        else:
            if (1<<count) & i != 0 :
                A.append(S[j])
            count+=1

    if cond(A)==True:
        ANS=max(ANS,len(A))

print(ANS)
0