結果
問題 | No.38 赤青白ブロック |
ユーザー | szkhts |
提出日時 | 2023-05-14 07:31:37 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 29 ms / 5,000 ms |
コード長 | 1,080 bytes |
コンパイル時間 | 84 ms |
コンパイル使用メモリ | 10,944 KB |
実行使用メモリ | 8,552 KB |
最終ジャッジ日時 | 2023-08-19 23:50:00 |
合計ジャッジ時間 | 1,668 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge10 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 15 ms
7,784 KB |
testcase_01 | AC | 29 ms
8,552 KB |
testcase_02 | AC | 16 ms
7,772 KB |
testcase_03 | AC | 16 ms
7,744 KB |
testcase_04 | AC | 16 ms
7,784 KB |
testcase_05 | AC | 15 ms
7,796 KB |
testcase_06 | AC | 17 ms
8,352 KB |
testcase_07 | AC | 16 ms
7,772 KB |
testcase_08 | AC | 16 ms
7,808 KB |
testcase_09 | AC | 17 ms
8,236 KB |
testcase_10 | AC | 16 ms
7,744 KB |
testcase_11 | AC | 15 ms
7,868 KB |
testcase_12 | AC | 16 ms
7,972 KB |
testcase_13 | AC | 16 ms
7,780 KB |
testcase_14 | AC | 15 ms
7,820 KB |
testcase_15 | AC | 16 ms
7,772 KB |
testcase_16 | AC | 19 ms
8,364 KB |
testcase_17 | AC | 16 ms
7,828 KB |
testcase_18 | AC | 17 ms
8,412 KB |
testcase_19 | AC | 16 ms
7,864 KB |
testcase_20 | AC | 16 ms
7,784 KB |
testcase_21 | AC | 16 ms
7,880 KB |
testcase_22 | AC | 29 ms
8,368 KB |
testcase_23 | AC | 16 ms
7,780 KB |
testcase_24 | AC | 18 ms
8,252 KB |
testcase_25 | AC | 15 ms
7,776 KB |
testcase_26 | AC | 15 ms
7,784 KB |
ソースコード
def solve(Kr, Kb, S): if is_valid(S, Kr, Kb): return len(S) strings = set([S]) for i in range(20): new_strings = set() for string in strings: for i, c in enumerate(string): if c == 'W': continue new_string = string[:i] + string[i+1:] if new_string in new_strings: continue if is_valid(new_string, Kr, Kb): return len(new_string) new_strings.add(new_string) strings = new_strings def is_valid(S, Kr, Kb): n = len(S) for i, c in enumerate(S): if c == 'B': if i >= Kb and S[i - Kb] == 'B': return False if i + Kb < n and S[i + Kb] == 'B': return False elif c == 'R': if i >= Kr and S[i - Kr] == 'R': return False if i + Kr < n and S[i + Kr] == 'R': return False return True Kr, Kb = map(int, input().split()) S = input() print(solve(Kr, Kb, S))