結果

問題 No.3021 Maximize eval
ユーザー 👑 rin204
提出日時 2025-02-14 23:42:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 197 ms / 2,000 ms
コード長 682 bytes
コンパイル時間 259 ms
コンパイル使用メモリ 82,788 KB
実行使用メモリ 129,144 KB
最終ジャッジ日時 2025-02-14 23:43:22
合計ジャッジ時間 3,708 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    S = input()
    T = []
    plus = True
    for i, s in enumerate(S):
        if s == "+":
            plus = True
            T.append("+")
        elif s == "-":
            plus = False
            T.append("-")
        elif s == "?":
            if plus:
                T.append("9")
            else:
                if S[i - 1] == "-":
                    T.append("1")
                elif i + 1 < len(S) and S[i + 1] not in "+-":
                    T.append("+")
                    plus = True
                else:
                    T.append("1")
        else:
            T.append(s)

    print(*T, sep="")


for _ in range(int(input())):
    solve()
0