結果
問題 | No.240 ナイト散歩 |
ユーザー |
|
提出日時 | 2020-04-22 20:13:50 |
言語 | Elixir (1.18.1) |
結果 |
AC
|
実行時間 | 577 ms / 2,000 ms |
コード長 | 863 bytes |
コンパイル時間 | 1,052 ms |
コンパイル使用メモリ | 62,572 KB |
実行使用メモリ | 55,264 KB |
最終ジャッジ日時 | 2024-12-31 04:35:39 |
合計ジャッジ時間 | 21,695 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
defmoduleMain dodef main doIO.read(:line)|> String.trim()|> String.split()|> Enum.map(&String.to_integer/1)|> solve|> IO.puts()enddef solve([x, y]) doif {x, y} in locations(), do: "YES", else: "NO"enddef locations dolocations1 = [{0, 0}] |> search_rec([])locations2 = locations1 |> search_rec([])locations3 = locations2 |> search_rec([])[locations1, locations2, locations3]|> Enum.concat()|> Enum.uniq()enddef search_rec([], result) doresultenddef search_rec([{x, y} | t], result) dot|> search_rec(result|> Enum.concat([{x - 2, y - 1},{x - 2, y + 1},{x - 1, y - 2},{x - 1, y + 2},{x + 1, y - 2},{x + 1, y + 2},{x + 2, y - 1},{x + 2, y + 1}]))endend