結果

問題 No.2226 Hello, Forgotten World!
ユーザー ID 21712
提出日時 2025-05-08 00:10:31
言語 Go
(1.23.4)
結果
WA  
実行時間 -
コード長 682 bytes
コンパイル時間 11,003 ms
コンパイル使用メモリ 238,548 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-05-08 00:10:44
合計ジャッジ時間 11,968 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import . "fmt"
import . "strings"

func main() {
	var t int
	Scan(&t)
	const H = "helloworld"
	bh := []byte(H)
	for ; t > 0; t-- {
		var n int
		var s string
		Scan(&n,&s)
		if len(s) != n {
			panic("bug")
		}
		if Contains(s, H) {
			s = ReplaceAll(s, "?", "a")
			Println(s)
			continue
		}
		b := []byte(s)
		for i := len(b)-len(bh); i >= 0; i-- {
			ok := true
			for j, ch := range bh {
				if b[i+j] != '?' && b[i+j] != ch {
					ok = false
					break
				}
			}
			if ok {
				for j, ch := range bh {
					b[i+j] = ch
				}
				break
			}
		}
		s = string(b)
		if Contains(s, H) {
			s = ReplaceAll(s, "?", "a")
			Println(s)
			continue
		}
		Println(-1)
	}
}
0