結果

問題 No.291 黒い文字列
ユーザー maspymaspy
提出日時 2020-04-10 13:32:16
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 992 bytes
コンパイル時間 1,365 ms
コンパイル使用メモリ 86,984 KB
実行使用メモリ 82,416 KB
最終ジャッジ日時 2023-10-13 01:59:12
合計ジャッジ時間 13,233 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 205 ms
76,304 KB
testcase_01 AC 206 ms
76,452 KB
testcase_02 AC 206 ms
76,476 KB
testcase_03 AC 204 ms
76,548 KB
testcase_04 AC 204 ms
76,556 KB
testcase_05 AC 207 ms
76,476 KB
testcase_06 AC 209 ms
76,480 KB
testcase_07 AC 204 ms
76,496 KB
testcase_08 AC 209 ms
76,604 KB
testcase_09 AC 208 ms
76,496 KB
testcase_10 AC 203 ms
76,428 KB
testcase_11 AC 320 ms
77,752 KB
testcase_12 AC 274 ms
77,768 KB
testcase_13 AC 205 ms
76,572 KB
testcase_14 AC 206 ms
76,452 KB
testcase_15 AC 206 ms
76,656 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0