結果

問題 No.38 赤青白ブロック
ユーザー titiatitia
提出日時 2021-11-30 17:55:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 975 ms / 5,000 ms
コード長 540 bytes
コンパイル時間 262 ms
コンパイル使用メモリ 87,248 KB
実行使用メモリ 78,040 KB
最終ジャッジ日時 2023-09-16 12:48:48
合計ジャッジ時間 25,214 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 875 ms
77,752 KB
testcase_01 AC 975 ms
77,976 KB
testcase_02 AC 825 ms
77,392 KB
testcase_03 AC 929 ms
78,040 KB
testcase_04 AC 876 ms
77,784 KB
testcase_05 AC 803 ms
77,484 KB
testcase_06 AC 850 ms
78,016 KB
testcase_07 AC 860 ms
77,728 KB
testcase_08 AC 788 ms
77,380 KB
testcase_09 AC 875 ms
77,068 KB
testcase_10 AC 743 ms
76,928 KB
testcase_11 AC 765 ms
77,084 KB
testcase_12 AC 819 ms
77,436 KB
testcase_13 AC 785 ms
77,396 KB
testcase_14 AC 860 ms
77,692 KB
testcase_15 AC 849 ms
77,312 KB
testcase_16 AC 814 ms
77,760 KB
testcase_17 AC 844 ms
77,452 KB
testcase_18 AC 842 ms
77,440 KB
testcase_19 AC 871 ms
77,320 KB
testcase_20 AC 881 ms
77,512 KB
testcase_21 AC 830 ms
77,696 KB
testcase_22 AC 922 ms
77,048 KB
testcase_23 AC 820 ms
77,504 KB
testcase_24 AC 858 ms
77,688 KB
testcase_25 AC 861 ms
77,528 KB
testcase_26 AC 880 ms
77,292 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