結果

問題 No.38 赤青白ブロック
ユーザー roiti46roiti46
提出日時 2015-02-11 22:09:15
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 809 bytes
コンパイル時間 476 ms
コンパイル使用メモリ 6,504 KB
実行使用メモリ 6,196 KB
最終ジャッジ日時 2023-09-05 23:41:48
合計ジャッジ時間 2,324 ms
ジャッジサーバーID
(参考情報)
judge12 / 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 11 ms
6,008 KB
testcase_11 AC 11 ms
6,008 KB
testcase_12 AC 10 ms
6,004 KB
testcase_13 AC 10 ms
6,036 KB
testcase_14 AC 11 ms
6,148 KB
testcase_15 AC 10 ms
5,920 KB
testcase_16 WA -
testcase_17 AC 11 ms
5,984 KB
testcase_18 WA -
testcase_19 AC 11 ms
6,020 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools
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 pull_r in itertools.combinations(r,i):
        for j in range(10):
            if 30-i-j <= ans: break
            for pull_b in itertools.combinations(b,j):
                s = [S[i] for i in range(30) if i not in pull_r+pull_b]
                if judge(s): ans = max(ans, len(s))
print ans
0