結果
問題 |
No.240 ナイト散歩
|
ユーザー |
![]() |
提出日時 | 2015-11-15 18:11:43 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 87 ms / 2,000 ms |
コード長 | 475 bytes |
コンパイル時間 | 153 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 12,288 KB |
最終ジャッジ日時 | 2024-10-07 21:16:00 |
合計ジャッジ時間 | 4,137 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
コンパイルメッセージ
Syntax OK
ソースコード
$dx = [-2, -2, -1, -1, 1, 1, 2, 2] $dy = [-1, 1, -2, 2, -2, 2, -1, 1] $cx = 0 $cy = 0 def process(x, y, n) if $cx == x && $cy == y return true elsif n >= 3 return false end find = false 8.times do |i| find = process(x + $dx[i], y + $dy[i], n + 1) if find break end end return find end str = gets.split $cx = str[0].to_i $cy = str[1].to_i if process(0, 0, 0) puts "YES" else puts "NO" end