結果
問題 |
No.2226 Hello, Forgotten World!
|
ユーザー |
![]() |
提出日時 | 2025-05-08 01:08:10 |
言語 | Go (1.23.4) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,412 bytes |
コンパイル時間 | 12,331 ms |
コンパイル使用メモリ | 236,216 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-05-08 01:08:23 |
合計ジャッジ時間 | 12,257 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 7 WA * 2 |
ソースコード
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 } } // コーナーケース // h?????????? // h??l??????? // h?????????d // h??l??????d // WA hhelloworld // AC helloworlda // AC helloworldd if ok && i > 0 && b[i-1] == 'h' { w := string(b[i:i+len(bh)-1]) ok = w != "?????????" && w != "??l??????" } if ok { x := []byte(s) for j, ch := range bh { x[i+j] = ch } ans = append(ans, ReplaceAll(string(x), "?", "a")) break } } if len(ans) > 0 { tmp := ans[0] Strings(ans) if tmp != ans[0] { println(s) println(tmp) println(ans[0]) //panic("bug") } return ans[0] } return "-1" } func init() { // check() } func check() { for t := 0; t < 1000; t++ { n := rand.Intn(40)+30 b := make([]byte, n) for i := range b { c := rand.Intn(100) if c < 26 { b[i] = bh[rand.Intn(len(bh))] } else { b[i] = '?' } } s := string(b) solve(n, s) } }