結果

問題 No.38 赤青白ブロック
ユーザー roiti46
提出日時 2015-02-11 22:33:14
言語 Python2
(2.7.18)
結果
AC  
実行時間 54 ms / 5,000 ms
コード長 556 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 7,040 KB
実行使用メモリ 7,424 KB
最終ジャッジ日時 2024-12-23 12:41:49
合計ジャッジ時間 1,392 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import combinations
def judge(s):
    for i in range(Kr,len(s)):
        if s[i] == s[i-Kr] == "R": return False
    for i in range(Kb,len(s)):
        if s[i] == s[i-Kb] == "B": return False
    return True

def rec(s):
    global ans
    if s in used: return
    used.add(s)
    if len(s) <= ans: return
    if judge(s):
        ans = len(s)
        return
    for i in range(len(s)):
        if s[i] == "W": continue
        rec(s[:i]+s[i+1:])

Kr,Kb = map(int,raw_input().split())
S = raw_input()
used = set([])
ans = 12
rec(S)
print ans
0