結果

問題 No.38 赤青白ブロック
コンテスト
ユーザー chocorusk
提出日時 2020-09-09 12:30:37
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 503 ms / 5,000 ms
コード長 774 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 274 ms
コンパイル使用メモリ 85,120 KB
実行使用メモリ 81,152 KB
最終ジャッジ日時 2026-06-05 14:32:07
合計ジャッジ時間 14,873 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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