結果
| 問題 | No.291 黒い文字列 |
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-04-10 13:32:16 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 992 bytes |
| 記録 | |
| コンパイル時間 | 133 ms |
| コンパイル使用メモリ | 85,248 KB |
| 実行使用メモリ | 88,320 KB |
| 最終ジャッジ日時 | 2026-04-04 15:51:16 |
| 合計ジャッジ時間 | 11,817 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 14 WA * 5 TLE * 1 -- * 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 x in 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, e, b, c in itertools.product(range(21), range(21), range(101), range(101)):
d = ques - (a + b + c + e)
if d < 0:
continue
x = solve(a, b, c, d, e)
if answer < x:
answer = x
print(answer)
maspy