結果
問題 |
No.2226 Hello, Forgotten World!
|
ユーザー |
![]() |
提出日時 | 2023-02-26 21:00:54 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 250 ms / 2,000 ms |
コード長 | 587 bytes |
コンパイル時間 | 101 ms |
コンパイル使用メモリ | 7,424 KB |
実行使用メモリ | 17,664 KB |
最終ジャッジ日時 | 2024-09-14 09:54:32 |
合計ジャッジ時間 | 2,192 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
コンパイルメッセージ
Main.rb:41: warning: ambiguous first argument; put parentheses or a space even after `-' operator Main.rb:8: warning: assigned but unused variable - best_idx Syntax OK
ソースコード
T = gets.to_i target = 'helloworld' T.times do n = gets.to_i s = gets.chomp best_idx = -1 list = [] (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 t = s.dup 10.times do |idx| if t[i + idx] == '?' t[i + idx] = target[idx] end end t.tr!('?', 'a') list << t end end if list.size > 0 puts list.sort[0] else puts -1 end end