結果

問題 No.113 宝探し
ユーザー gemmaro
提出日時 2020-04-19 13:59:25
言語 Elixir
(1.18.1)
結果
AC  
実行時間 572 ms / 5,000 ms
コード長 456 bytes
コンパイル時間 1,091 ms
コンパイル使用メモリ 62,392 KB
実行使用メモリ 56,572 KB
最終ジャッジ日時 2024-12-31 04:27:30
合計ジャッジ時間 17,630 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

defmodule Main do
  def main do
    IO.read(:line)
    |> String.trim()
    |> String.to_charlist()
    |> solve
    |> IO.puts()
  end

  def solve(s) do
    solve_rec(s, 0, 0)
  end

  def solve_rec([], x, y) do
    :math.sqrt(x * x + y * y)
  end

  def solve_rec([c | t], x, y) do
    case c do
      ?N -> solve_rec(t, x, y + 1)
      ?E -> solve_rec(t, x + 1, y)
      ?W -> solve_rec(t, x - 1, y)
      ?S -> solve_rec(t, x, y - 1)
    end
  end
end
0