結果

問題 No.2226 Hello, Forgotten World!
コンテスト
ユーザー aaaaaaaaaa2230
提出日時 2023-02-24 22:50:18
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 234 ms / 2,000 ms
コード長 689 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 734 ms
コンパイル使用メモリ 85,504 KB
実行使用メモリ 81,024 KB
最終ジャッジ日時 2026-04-04 03:40:08
合計ジャッジ時間 2,093 ms
ジャッジサーバーID
(参考情報)
judge5_1 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

hello = "helloworld"

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

    ans = "{"
    for i in range(n-9):
        ok = 1
        for j in range(10):
            if S[i+j] != "?" and S[i+j] != hello[j]:
                ok = 0

        if ok == 0:
            continue

        cand = []
        for j,s in enumerate(S):
            if i <= j < i+10:
                cand.append(hello[j-i])
            else:
                if s == "?":
                    s = "a"
                cand.append(s)

        cand = "".join(cand)
        if cand < ans:
            ans = cand
    if ans == "{":
        ans = -1
    return ans      

t = int(input())
for _ in range(t):
    print(solve())
0