結果

問題 No.2226 Hello, Forgotten World!
ユーザー 👑 Kazun
提出日時 2023-02-24 21:38:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 108 ms / 2,000 ms
コード長 600 bytes
コンパイル時間 252 ms
コンパイル使用メモリ 82,064 KB
実行使用メモリ 76,140 KB
最終ジャッジ日時 2024-09-13 05:13:23
合計ジャッジ時間 1,571 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

def substitutable(S,T):
    return all(S[i]==T[i] or S[i]=="?" or T[i]=="?" for i in range(len(S)))

def solve():
    N=int(input())
    S=input()

    H="helloworld"
    Ans=""
    exist=0
    for i in range(N-len(H),-1,-1):
        if substitutable(S[i:i+len(H)],H):
            U=S[:i].replace("?","a")+H+S[i+len(H):].replace("?","a")
            if exist==0:
                Ans=U
            else:
                Ans=min(Ans,U)
            exist=1
    return Ans if exist else -1

#==================================================
T=int(input())
print(*[solve() for t in range(T)], sep="\n")
0