結果
| 問題 |
No.291 黒い文字列
|
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-04-10 13:18:05 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 981 bytes |
| コンパイル時間 | 241 ms |
| コンパイル使用メモリ | 82,048 KB |
| 実行使用メモリ | 77,184 KB |
| 最終ジャッジ日時 | 2024-09-14 23:17:52 |
| 合計ジャッジ時間 | 8,985 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 20 WA * 6 |
ソースコード
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import itertools
S = read().rstrip().decode()
ques = S.count('?')
def solve(a, b, c, d, e):
stack = ['I'] * e + ['O'] * d + ['R'] * c + ['U'] * b + ['K'] * a
K = 0
KU = 0
KUR = 0
KURO = 0
KUROI = 0
for i, x in enumerate(S):
if x == '?':
x = stack.pop()
if x == 'K':
K += 1
elif x == 'U' and K:
K -= 1
KU += 1
elif x == 'R' and KU:
KU -= 1
KUR += 1
elif x == 'O' and KUR:
KUR -= 1
KURO += 1
elif x == 'I' and KURO:
KURO -= 1
KUROI += 1
return KUROI
answer = 0
for a, b, c, d in itertools.product(range(21), repeat=4):
e = ques - (a + b + c + d)
if e < 0:
continue
x = solve(a, b, c, d, e)
if answer < x:
answer = x
print(answer)
maspy