結果

問題 No.2226 Hello, Forgotten World!
ユーザー tamatotamato
提出日時 2023-02-24 21:29:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 349 ms / 2,000 ms
コード長 1,020 bytes
コンパイル時間 288 ms
コンパイル使用メモリ 87,084 KB
実行使用メモリ 83,360 KB
最終ジャッジ日時 2023-10-11 05:51:05
合計ジャッジ時間 2,986 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,308 KB
testcase_01 AC 308 ms
83,360 KB
testcase_02 AC 349 ms
79,488 KB
testcase_03 AC 234 ms
78,176 KB
testcase_04 AC 120 ms
77,220 KB
testcase_05 AC 230 ms
78,880 KB
testcase_06 AC 150 ms
77,864 KB
testcase_07 AC 173 ms
77,584 KB
testcase_08 AC 110 ms
77,012 KB
testcase_09 AC 178 ms
77,484 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353


def main():
    import sys
    input = sys.stdin.readline

    for _ in range(int(input())):
        N = int(input())
        S = input().rstrip('\n')
        H = "helloworld"

        A = []
        for i in range(N - 10 + 1):
            T = []
            ok = 1
            for j in range(N):
                if i <= j <= i + 9:
                    if S[j] == "?":
                        T.append(H[j - i])
                    else:
                        if S[j] != H[j - i]:
                            ok = 0
                            break
                        else:
                            T.append(S[j])
                else:
                    if S[j] == "?":
                        T.append("a")
                    else:
                        T.append(S[j])
            if not ok:
                continue
            A.append("".join(T))
        if A:
            A.sort()
            print(A[0])
        else:
            print(-1)


if __name__ == '__main__':
    main()
0