結果

問題 No.2226 Hello, Forgotten World!
ユーザー gr1msl3y
提出日時 2023-03-18 15:45:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 306 ms / 2,000 ms
コード長 630 bytes
コンパイル時間 241 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 81,920 KB
最終ジャッジ日時 2024-09-18 13:20:53
合計ジャッジ時間 1,955 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

T='helloworld'
def solve(N,S):
    ans=[]
    for i in range(N-10,-1,-1):
        for j in range(10):
        	if S[i+j]!='?' and S[i+j]!=T[j]: break
        else:
            res=[]
            for j in range(N):
                if i<=j<i+10:
                    res.append(T[j-i])
                elif S[j]=='?':
                    res.append('a')
                else:
                    res.append(S[j])
            ans.append(''.join(res))
    if not ans:
    	return '-1'
    return sorted(ans)[0]

t=int(input())
ans=[]
for _ in range(t):
    N=int(input())
    S=input()
    ans.append(solve(N,S))

print(*ans,sep='\n')
0