結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 370 ms
80,844 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 71 ms
76,340 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 116 ms
79,836 KB
testcase_10 AC 73 ms
76,320 KB
testcase_11 AC 71 ms
76,380 KB
testcase_12 AC 73 ms
76,248 KB
testcase_13 AC 71 ms
76,644 KB
testcase_14 AC 69 ms
76,692 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 124 ms
79,984 KB
testcase_18 WA -
testcase_19 AC 107 ms
78,988 KB
testcase_20 AC 87 ms
78,912 KB
testcase_21 WA -
testcase_22 AC 296 ms
80,100 KB
testcase_23 WA -
testcase_24 AC 132 ms
79,960 KB
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[k] for k in range(30) if k not in pull_r+pull_b]
                if judge(s): ans = max(ans, len(s))
print ans
0