結果

問題 No.38 赤青白ブロック
ユーザー roiti46roiti46
提出日時 2015-02-11 22:17:41
言語 PyPy2
(7.3.15)
結果
WA  
実行時間 -
コード長 762 bytes
コンパイル時間 259 ms
コンパイル使用メモリ 77,612 KB
実行使用メモリ 80,292 KB
最終ジャッジ日時 2023-09-05 23:50:39
合計ジャッジ時間 42,964 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 74 ms
76,624 KB
testcase_11 AC 74 ms
76,064 KB
testcase_12 AC 75 ms
76,272 KB
testcase_13 AC 73 ms
76,328 KB
testcase_14 AC 75 ms
76,444 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

Kr,Kb = map(int,raw_input().split())
S = list(raw_input())
r = [i for i in range(30) if S[i] == "R"]
b = [i for i in range(30) if S[i] == "B"]
ans = 0
for i in range(10):
    if 30-i <= ans: break
    for j in range(10):
        if 30-i-j <= ans: break
        s = [S[k] for k in range(30) if k not in (pull_r+pull_b for pull_r in combinations(r,i) for pull_b in combinations(b,j))]
        if judge(s): ans = max(ans, len(s))
print ans
0