結果
| 問題 |
No.38 赤青白ブロック
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-21 14:24:03 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 1,024 ms / 5,000 ms |
| コード長 | 669 bytes |
| コンパイル時間 | 407 ms |
| コンパイル使用メモリ | 82,420 KB |
| 実行使用メモリ | 76,464 KB |
| 最終ジャッジ日時 | 2024-10-08 06:24:29 |
| 合計ジャッジ時間 | 28,347 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 27 |
ソースコード
import itertools
R, B = map(int, input().split())
S = input()
ans = 0
for t in itertools.product((0, 1), repeat=20):
j = 0
S_new = []
for s in S:
if s == 'W':
S_new.append(s)
else:
if t[j]:
S_new.append(s)
j += 1
l = len(S_new)
for j in range(l):
if S_new[j] == 'R':
if (j - R >= 0 and S_new[j - R] == 'R') or (j + R < l and S_new[j + R] == 'R'):
break
elif S_new[j] == 'B':
if (j - B >= 0 and S_new[j - B] == 'B') or (j + B < l and S_new[j + B] == 'B'):
break
else:
ans = max(ans, l)
print(ans)