結果

問題 No.2226 Hello, Forgotten World!
コンテスト
ユーザー AP25
提出日時 2026-06-18 15:34:27
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 731 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 293 ms
コンパイル使用メモリ 85,120 KB
実行使用メモリ 60,672 KB
最終ジャッジ日時 2026-06-18 15:34:29
合計ジャッジ時間 1,643 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

# 全探索して複数候補がある場合はできるだけ後ろにhelloworldをおいて余った?にはaをあてがう

T = int(input())

word = "helloworld"
num = len(word)

for _ in range(T):

    N = int(input())
    S = list(input())

    idx = -1
    for s in range(N-num,-1,-1):
        if S[s] != "h" and S[s] != "?":
            continue

        if all(S[s+i] == word[i] or S[s+i] == "?" for i in range(num)):
            idx = s
            break

    if idx == -1:
        print(-1)
        continue

    for i in range(num):
        if S[idx+i] == "?":
            S[idx+i] = word[i]

    for i in range(N):
        if S[i] == "?":
            S[i] = "a"

    print("".join(S))
0