結果

問題 No.2226 Hello, Forgotten World!
ユーザー nephrologistnephrologist
提出日時 2023-02-25 18:36:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 229 ms / 2,000 ms
コード長 840 bytes
コンパイル時間 319 ms
コンパイル使用メモリ 87,016 KB
実行使用メモリ 125,108 KB
最終ジャッジ日時 2023-10-11 15:34:30
合計ジャッジ時間 2,218 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,120 KB
testcase_01 AC 229 ms
125,108 KB
testcase_02 AC 107 ms
77,672 KB
testcase_03 AC 110 ms
77,888 KB
testcase_04 AC 90 ms
76,180 KB
testcase_05 AC 108 ms
77,544 KB
testcase_06 AC 98 ms
77,528 KB
testcase_07 AC 102 ms
76,844 KB
testcase_08 AC 85 ms
75,924 KB
testcase_09 AC 103 ms
77,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

input = sys.stdin.readline
hoge = list("helloworld")
t = int(input())
for _ in range(t):
    n = int(input())
    s = list(input().rstrip())
    for i in range(n):
        if s[i] == "?":
            s[i] = "`"
    ans = -1
    kouho = []
    for start in range(n - 9)[::-1]:
        okflag = 1
        for i in range(10):
            if s[start + i] == hoge[i] or s[start + i] == "`":
                continue
            else:
                okflag = 0
                break
        if okflag:
            temp = s[:]
            for i in range(10):
                temp[i + start] = hoge[i]
            kouho.append(temp)

    if not kouho:
        print(ans)
        continue
    kouho.sort()
    ans = kouho[0]
    for i in range(n):
        if ans[i] == "`":
            ans[i] = "a"
    print("".join(ans))
    # exit()
0