結果

問題 No.38 赤青白ブロック
ユーザー roiti46roiti46
提出日時 2015-02-11 22:33:14
言語 Python2
(2.7.18)
結果
AC  
実行時間 61 ms / 5,000 ms
コード長 556 bytes
コンパイル時間 1,231 ms
コンパイル使用メモリ 6,496 KB
実行使用メモリ 7,032 KB
最終ジャッジ日時 2023-08-25 00:59:24
合計ジャッジ時間 2,859 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
5,992 KB
testcase_01 AC 43 ms
7,016 KB
testcase_02 AC 16 ms
6,344 KB
testcase_03 AC 13 ms
5,984 KB
testcase_04 AC 11 ms
6,020 KB
testcase_05 AC 11 ms
6,040 KB
testcase_06 AC 30 ms
6,948 KB
testcase_07 AC 19 ms
6,144 KB
testcase_08 AC 11 ms
6,120 KB
testcase_09 AC 33 ms
6,908 KB
testcase_10 AC 11 ms
6,008 KB
testcase_11 AC 11 ms
5,980 KB
testcase_12 AC 11 ms
5,980 KB
testcase_13 AC 11 ms
5,912 KB
testcase_14 AC 11 ms
5,984 KB
testcase_15 AC 15 ms
6,132 KB
testcase_16 AC 24 ms
6,328 KB
testcase_17 AC 13 ms
6,268 KB
testcase_18 AC 18 ms
6,072 KB
testcase_19 AC 16 ms
6,200 KB
testcase_20 AC 14 ms
6,032 KB
testcase_21 AC 12 ms
6,060 KB
testcase_22 AC 61 ms
7,032 KB
testcase_23 AC 11 ms
5,988 KB
testcase_24 AC 22 ms
6,232 KB
testcase_25 AC 12 ms
5,996 KB
testcase_26 AC 13 ms
6,004 KB
権限があれば一括ダウンロードができます

ソースコード

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