結果

問題 No.2226 Hello, Forgotten World!
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2023-02-24 22:50:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 297 ms / 2,000 ms
コード長 689 bytes
コンパイル時間 452 ms
コンパイル使用メモリ 87,012 KB
実行使用メモリ 77,220 KB
最終ジャッジ日時 2023-10-11 06:40:45
合計ジャッジ時間 2,470 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,312 KB
testcase_01 AC 297 ms
77,220 KB
testcase_02 AC 138 ms
76,968 KB
testcase_03 AC 133 ms
77,024 KB
testcase_04 AC 93 ms
76,808 KB
testcase_05 AC 135 ms
77,192 KB
testcase_06 AC 105 ms
76,680 KB
testcase_07 AC 114 ms
76,944 KB
testcase_08 AC 97 ms
76,800 KB
testcase_09 AC 121 ms
76,996 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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