結果

問題 No.2226 Hello, Forgotten World!
ユーザー 👑 KazunKazun
提出日時 2023-02-24 21:38:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 176 ms / 2,000 ms
コード長 600 bytes
コンパイル時間 1,236 ms
コンパイル使用メモリ 87,028 KB
実行使用メモリ 77,820 KB
最終ジャッジ日時 2023-10-11 05:58:34
合計ジャッジ時間 2,943 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,096 KB
testcase_01 AC 176 ms
77,012 KB
testcase_02 AC 119 ms
77,428 KB
testcase_03 AC 119 ms
77,232 KB
testcase_04 AC 101 ms
76,344 KB
testcase_05 AC 120 ms
77,820 KB
testcase_06 AC 110 ms
77,020 KB
testcase_07 AC 116 ms
76,912 KB
testcase_08 AC 93 ms
76,204 KB
testcase_09 AC 120 ms
77,452 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def substitutable(S,T):
    return all(S[i]==T[i] or S[i]=="?" or T[i]=="?" for i in range(len(S)))

def solve():
    N=int(input())
    S=input()

    H="helloworld"
    Ans=""
    exist=0
    for i in range(N-len(H),-1,-1):
        if substitutable(S[i:i+len(H)],H):
            U=S[:i].replace("?","a")+H+S[i+len(H):].replace("?","a")
            if exist==0:
                Ans=U
            else:
                Ans=min(Ans,U)
            exist=1
    return Ans if exist else -1

#==================================================
T=int(input())
print(*[solve() for t in range(T)], sep="\n")
0