結果

問題 No.38 赤青白ブロック
ユーザー yaoshimaxyaoshimax
提出日時 2015-02-21 20:51:40
言語 Python2
(2.7.18)
結果
AC  
実行時間 75 ms / 5,000 ms
コード長 578 bytes
コンパイル時間 70 ms
コンパイル使用メモリ 6,596 KB
実行使用メモリ 6,732 KB
最終ジャッジ日時 2023-08-25 01:00:31
合計ジャッジ時間 1,969 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
5,932 KB
testcase_01 AC 62 ms
6,704 KB
testcase_02 AC 29 ms
6,056 KB
testcase_03 AC 17 ms
6,004 KB
testcase_04 AC 12 ms
5,880 KB
testcase_05 AC 11 ms
5,812 KB
testcase_06 AC 65 ms
6,644 KB
testcase_07 AC 36 ms
6,188 KB
testcase_08 AC 11 ms
5,960 KB
testcase_09 AC 69 ms
6,732 KB
testcase_10 AC 10 ms
6,048 KB
testcase_11 AC 11 ms
5,948 KB
testcase_12 AC 11 ms
5,884 KB
testcase_13 AC 11 ms
6,072 KB
testcase_14 AC 11 ms
5,896 KB
testcase_15 AC 24 ms
6,000 KB
testcase_16 AC 36 ms
6,068 KB
testcase_17 AC 18 ms
6,020 KB
testcase_18 AC 32 ms
6,140 KB
testcase_19 AC 23 ms
6,100 KB
testcase_20 AC 22 ms
6,156 KB
testcase_21 AC 16 ms
5,956 KB
testcase_22 AC 75 ms
6,712 KB
testcase_23 AC 11 ms
5,956 KB
testcase_24 AC 50 ms
6,136 KB
testcase_25 AC 17 ms
5,992 KB
testcase_26 AC 16 ms
5,992 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def judge(S):
    global Kr
    global Kb
    for i in range(len(S)):
        if S[i]=='R' and i+Kr < len(S) and S[i+Kr] == 'R':
            return False
        if S[i]=='B' and i+Kb < len(S) and S[i+Kb] =='B':
            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= max(ans,len(S))
        return
    for i in range(len(S)):
        if S[i]!='W':
             rec(S[:i]+S[i+1:])

Kr,Kb=map(int,raw_input().split())
S=raw_input()
ans =0
used = set([])
rec(S)
print ans
0