結果
問題 |
No.2226 Hello, Forgotten World!
|
ユーザー |
![]() |
提出日時 | 2023-02-26 20:56:43 |
言語 | Ruby (3.4.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 558 bytes |
コンパイル時間 | 272 ms |
コンパイル使用メモリ | 7,296 KB |
実行使用メモリ | 12,288 KB |
最終ジャッジ日時 | 2024-09-14 09:50:58 |
合計ジャッジ時間 | 2,135 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | WA * 9 |
コンパイルメッセージ
Main.rb:40: warning: ambiguous first argument; put parentheses or a space even after `-' operator Syntax OK
ソースコード
T = gets.to_i target = 'helloworld' T.times do n = gets.to_i s = gets.chomp best_idx = -1 (n - 10).downto(0) do |i| ok = true idx = 0 while ok && idx < 10 if target[idx] == s[i + idx] || s[i + idx] == '?' # NOOP else ok = false end idx += 1 end if ok best_idx = i break end end if best_idx != -1 10.times do |i| if s[best_idx + i] == '?' s[best_idx + i] = target[i] end end s.tr!('?', 'a') puts s else puts -1 end end