結果

問題 No.38 赤青白ブロック
ユーザー roiti46roiti46
提出日時 2015-02-11 22:36:17
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 129 ms / 5,000 ms
コード長 536 bytes
コンパイル時間 2,095 ms
コンパイル使用メモリ 77,408 KB
実行使用メモリ 80,340 KB
最終ジャッジ日時 2023-08-25 00:59:35
合計ジャッジ時間 5,735 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
78,932 KB
testcase_01 AC 129 ms
79,996 KB
testcase_02 AC 96 ms
79,104 KB
testcase_03 AC 83 ms
78,984 KB
testcase_04 AC 73 ms
76,404 KB
testcase_05 AC 71 ms
76,724 KB
testcase_06 AC 122 ms
80,092 KB
testcase_07 AC 104 ms
79,876 KB
testcase_08 AC 70 ms
76,676 KB
testcase_09 AC 115 ms
79,140 KB
testcase_10 AC 71 ms
76,396 KB
testcase_11 AC 72 ms
76,596 KB
testcase_12 AC 73 ms
76,548 KB
testcase_13 AC 73 ms
76,380 KB
testcase_14 AC 73 ms
76,332 KB
testcase_15 AC 93 ms
79,584 KB
testcase_16 AC 103 ms
79,348 KB
testcase_17 AC 84 ms
79,272 KB
testcase_18 AC 96 ms
79,424 KB
testcase_19 AC 96 ms
79,064 KB
testcase_20 AC 90 ms
79,344 KB
testcase_21 AC 89 ms
79,820 KB
testcase_22 AC 115 ms
80,340 KB
testcase_23 AC 73 ms
76,180 KB
testcase_24 AC 108 ms
79,460 KB
testcase_25 AC 80 ms
78,944 KB
testcase_26 AC 83 ms
79,276 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

def rec(s):
    global ans
    if s in used or len(s) <= ans: return
    used.add(s)
    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