結果
問題 |
No.2226 Hello, Forgotten World!
|
ユーザー |
![]() |
提出日時 | 2025-05-08 00:14:18 |
言語 | Go (1.23.4) |
結果 |
WA
|
実行時間 | - |
コード長 | 704 bytes |
コンパイル時間 | 11,340 ms |
コンパイル使用メモリ | 248,924 KB |
実行使用メモリ | 7,848 KB |
最終ジャッジ日時 | 2025-05-08 00:14:30 |
合計ジャッジ時間 | 12,355 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | WA * 9 |
ソースコード
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 Contains(s, H) { s = ReplaceAll(s, "?", "a") Println(s) continue } b := []byte(s) found := -1 for i := len(b)-len(bh); i >= 0; i-- { if i < found { break } 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 } found = i - len(bh) } } s = string(b) if Contains(s, H) { s = ReplaceAll(s, "?", "a") Println(s) continue } Println(-1) } }