結果

問題 No.38 赤青白ブロック
ユーザー chocoruskchocorusk
提出日時 2020-09-09 12:30:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 743 ms / 5,000 ms
コード長 774 bytes
コンパイル時間 395 ms
コンパイル使用メモリ 86,964 KB
実行使用メモリ 77,792 KB
最終ジャッジ日時 2023-08-21 07:52:36
合計ジャッジ時間 20,351 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 658 ms
77,160 KB
testcase_01 AC 665 ms
77,348 KB
testcase_02 AC 622 ms
77,304 KB
testcase_03 AC 644 ms
77,172 KB
testcase_04 AC 651 ms
76,936 KB
testcase_05 AC 645 ms
77,020 KB
testcase_06 AC 743 ms
77,792 KB
testcase_07 AC 676 ms
77,576 KB
testcase_08 AC 638 ms
77,188 KB
testcase_09 AC 683 ms
77,456 KB
testcase_10 AC 644 ms
77,012 KB
testcase_11 AC 641 ms
77,008 KB
testcase_12 AC 630 ms
76,896 KB
testcase_13 AC 625 ms
77,100 KB
testcase_14 AC 635 ms
77,012 KB
testcase_15 AC 688 ms
77,404 KB
testcase_16 AC 680 ms
77,344 KB
testcase_17 AC 652 ms
77,636 KB
testcase_18 AC 687 ms
77,640 KB
testcase_19 AC 664 ms
77,564 KB
testcase_20 AC 708 ms
77,700 KB
testcase_21 AC 668 ms
77,140 KB
testcase_22 AC 694 ms
77,668 KB
testcase_23 AC 653 ms
76,972 KB
testcase_24 AC 646 ms
77,448 KB
testcase_25 AC 657 ms
77,220 KB
testcase_26 AC 674 ms
77,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read=sys.stdin.buffer.read
readline=sys.stdin.readline
readlines=sys.stdin.buffer.readlines

kr, kb=map(int, readline().split())
s=readline().rstrip()
ans=0
for i in range(1<<20):
    t=""
    cnt=0
    for j in range(30):
        if s[j]=='R':
            if (i&(1<<cnt))==0:
                t+='R'
            cnt+=1
        elif s[j]=='B':
            if (i&(1<<cnt))==0:
                t+='B'
            cnt+=1
        else:
            t+='W'
    if len(t)<ans:
        continue
    dame=False
    for j, c in enumerate(t):
        if c=='R' and j+kr<len(t) and t[j+kr]=='R':
            dame=True
            break
        elif c=='B' and j+kb<len(t) and t[j+kb]=='B':
            dame=True
            break
    if not dame:
        ans=len(t)
print(ans)
0