結果

問題 No.2226 Hello, Forgotten World!
ユーザー ああいいああいい
提出日時 2023-02-25 17:16:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 147 ms / 2,000 ms
コード長 1,433 bytes
コンパイル時間 294 ms
コンパイル使用メモリ 86,940 KB
実行使用メモリ 77,348 KB
最終ジャッジ日時 2023-10-11 14:41:38
合計ジャッジ時間 2,526 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,032 KB
testcase_01 AC 147 ms
76,500 KB
testcase_02 AC 124 ms
77,348 KB
testcase_03 AC 117 ms
77,100 KB
testcase_04 AC 92 ms
76,548 KB
testcase_05 AC 113 ms
77,048 KB
testcase_06 AC 99 ms
77,040 KB
testcase_07 AC 107 ms
77,068 KB
testcase_08 AC 88 ms
76,496 KB
testcase_09 AC 107 ms
77,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())
U = "helloworld"

for _ in range(T):
    N = int(input())
    S = input()

    l = []
    for i in  range(N - 10 + 1):
        flag = True
        for j in range(10):
            if S[i + j] == "?" or S[i + j] == U[j]:
                pass
            else:
                flag = False
                break
        if flag:
            l.append(i)
    while len(l) > 1:
        i = l.pop()
        j = l.pop()
        flag = True
        for k in range(N):
            if i <= k <= i + 9:
                c = U[k - i]
            else:
                if S[k] == "?":
                    c = "a"
                else:
                    c = S[k]
            if j <= k <= j + 9:
                d = U[k-j]
            else:
                if S[k] == "?":
                    d = "a"
                else:
                    d = S[k]
            if c < d:
                l.append(i)
                flag = False
                break
            elif c > d:
                l.append(j)
                flag = False
                break
        if flag:
            l.append(i)
    if len(l) == 0:
        print(-1)
        continue
    i = l[0]
    ans = []
    for k in range(N):
        if i <= k <= i + 9:
            ans.append(U[k-i])
        else:
            if S[k] == "?":
                ans.append("a")
            else:
                ans.append(S[k])
    print("".join(ans))
            
        
0