結果

問題 No.38 赤青白ブロック
ユーザー chocorusk
提出日時 2020-09-09 12:46:00
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 1,240 ms / 5,000 ms
コード長 688 bytes
コンパイル時間 316 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-12-14 19:07:22
合計ジャッジ時間 3,730 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

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

kr, kb=map(int, readline().split())
s=readline().rstrip().decode()
idx=[i for i, c in enumerate(s) if c!='W']
import itertools
for l in range(20):
    for myon in itertools.combinations(idx, l):
        t=[c for i, c in enumerate(s) if i not in myon]
        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:
            print(30-l)
            exit()
0