結果
問題 |
No.2226 Hello, Forgotten World!
|
ユーザー |
![]() |
提出日時 | 2025-05-08 00:38:06 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 135 ms / 2,000 ms |
コード長 | 1,032 bytes |
コンパイル時間 | 14,727 ms |
コンパイル使用メモリ | 241,220 KB |
実行使用メモリ | 8,360 KB |
最終ジャッジ日時 | 2025-05-08 00:38:22 |
合計ジャッジ時間 | 12,360 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
ソースコード
package main import . "fmt" import . "strings" import . "sort" import "math/rand" func main() { var t int Scan(&t) for ; t > 0; t-- { var n int var s string Scan(&n,&s) Println(solve(n, s)) } } const H = "helloworld" var bh = []byte(H) func solve(n int, s string) string { if Contains(s, H) { return ReplaceAll(s, "?", "a") } b := []byte(s) ans := []string{} 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 { x := []byte(s) for j, ch := range bh { x[i+j] = ch } ans = append(ans, ReplaceAll(string(x), "?", "a")) } } if len(ans) > 0 { Strings(ans) return ans[0] } return "-1" } func init() { // check() } func check() { for t := 0; t < 5; t++ { n := rand.Intn(40)+30 b := make([]byte, n) for i := range b { c := rand.Intn(120) if c < 26 { b[i] = byte(c + 'a') } else { b[i] = '?' } } s := string(b) println(s) println(solve(n, s)) } }