結果

問題 No.1609 String Division Machine
ユーザー 👑 rin204
提出日時 2022-01-18 01:37:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 131 ms / 2,000 ms
コード長 597 bytes
コンパイル時間 246 ms
コンパイル使用メモリ 82,216 KB
実行使用メモリ 87,832 KB
最終ジャッジ日時 2024-11-23 13:06:50
合計ジャッジ時間 3,969 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

S = input()
n = len(S)

used = [False] * n
T = ["?"] * n
for i in range(n):
    if S[i] == "?":
        used[i] = True
    else:
        T[i] = S[i]
        
cnt = [0] * n
for i in range(1, 28):
    max_ = "a"
    br = True
    for j in range(n - 1, -1, -1):
        if used[j]:
            continue
        elif S[j] >= max_:
            max_ = S[j]
            used[j] = True
            cnt[j] = i
            br = False
    if br:
        break

ma = i - 1
t = "a"
for j in range(n - 1, -1, -1):
    if T[j] == "?":
        T[j] = t
    elif cnt[j] == ma:
        t = T[j]
print(*T, sep="")


0