結果

問題 No.2226 Hello, Forgotten World!
ユーザー rlangevinrlangevin
提出日時 2023-02-24 21:55:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 398 ms / 2,000 ms
コード長 922 bytes
コンパイル時間 295 ms
コンパイル使用メモリ 87,248 KB
実行使用メモリ 84,492 KB
最終ジャッジ日時 2023-10-11 06:11:18
合計ジャッジ時間 2,869 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,060 KB
testcase_01 AC 398 ms
84,492 KB
testcase_02 AC 264 ms
78,164 KB
testcase_03 AC 200 ms
78,504 KB
testcase_04 AC 110 ms
76,916 KB
testcase_05 AC 200 ms
77,828 KB
testcase_06 AC 136 ms
77,556 KB
testcase_07 AC 163 ms
77,396 KB
testcase_08 AC 100 ms
77,236 KB
testcase_09 AC 169 ms
78,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def check(X, Y):
    for i in range(len(X)):
        if X[i] != Y[i] and X[i] != "?":
            return 0
    return 1

T = int(input())
hello = list("helloworld")
for _ in range(T):
    N = int(input())
    S = list(input())
    flag = 0
    for i in range(N - 10, -1, -1):
        if S[i:i+10] == hello:
            flag = 1
            break
    if flag:
        for i in range(N):
            if S[i] == "?":
                S[i] = "a"
        print("".join(S))
        continue
        
        
    L = []
    for i in range(N - 10, -1, -1):
        temp = [None] * N
        if check(S[i:i+10], hello):
            for j in range(N):
                temp[j] = S[j]
            temp[i:i+10] = hello
            for j in range(N):
                if temp[j] == "?":
                    temp[j] = "a"
            L.append("".join(temp))
    if not L:
        print(-1)
        continue
    else:
        print(min(L))
0