結果

問題 No.2226 Hello, Forgotten World!
ユーザー ニックネームニックネーム
提出日時 2023-02-25 00:05:11
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 542 bytes
コンパイル時間 104 ms
コンパイル使用メモリ 10,712 KB
実行使用メモリ 7,944 KB
最終ジャッジ日時 2023-10-11 07:06:45
合計ジャッジ時間 966 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
7,780 KB
testcase_01 AC 17 ms
7,944 KB
testcase_02 AC 39 ms
7,704 KB
testcase_03 AC 18 ms
7,704 KB
testcase_04 AC 17 ms
7,784 KB
testcase_05 AC 18 ms
7,772 KB
testcase_06 AC 18 ms
7,780 KB
testcase_07 AC 17 ms
7,856 KB
testcase_08 AC 17 ms
7,904 KB
testcase_09 AC 18 ms
7,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

for _ in range(int(input())):
    n = int(input())
    s = input()
    t = "helloworld"
    ans = "-1"
    for i in range(n-10,-1,-1):
        if t in s: ans = s; break
        if s[i-9:i+1]==t[:9]+"?": ans = s[:i-9]+t+s[i+1:]; break
        f = s[i-1:i]=="h"
        for j in range(9):
            if "?"!=s[i+j]!=t[j+1]: f = False
        if f: ans = s[:i-1]+t+s[i+9:]; break
        f = True
        for j in range(10):
            if "?"!=s[i+j]!=t[j]: f = False
        if f: ans = s[:i]+t+s[i+10:]; break
    print(ans.replace("?","a"))
0