結果

問題 No.1609 String Division Machine
ユーザー rin204
提出日時 2022-01-18 01:36:19
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 597 bytes
コンパイル時間 365 ms
コンパイル使用メモリ 82,320 KB
実行使用メモリ 88,068 KB
最終ジャッジ日時 2024-11-23 13:06:01
合計ジャッジ時間 4,310 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 29 WA * 8
権限があれば一括ダウンロードができます

ソースコード

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, 27):
    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