Submission #17395021
Source Code Expand
defmodule Main do
def main do
n = IO.read(:line) |> String.trim() |> String.to_integer()
1..n
|> Enum.reduce([], fn _, acc ->
list =
IO.read(:line) |> String.trim() |> String.split(" ") |> Enum.map(&String.to_integer/1)
[list | acc]
end)
|> Enum.reverse()
|> solve()
|> IO.puts()
end
@doc ~S"""
https://atcoder.jp/contests/abc172/tasks/abc172_b
## Examples
iex> Arc089A.solve([[3, 1, 2], [6, 1, 1]])
"Yes"
iex> Arc089A.solve([[2, 100, 100]])
"No"
iex> Arc089A.solve([[5, 1, 1], [100, 1, 1]])
"No"
"""
def solve(list_of_lists) do
list_of_lists
|> Enum.reduce_while([0, 0, 0, "No"], fn next, acc ->
do_solve(next, acc)
end)
|> Enum.at(-1)
end
defp do_solve([next_t, next_x, next_y], [t, x, y, _])
when abs(next_x - x) + abs(next_y - y) > next_t - t,
do: {:halt, [next_t, next_x, next_y, "No"]}
defp do_solve([next_t, next_x, next_y], [t, x, y, _])
when rem(next_t - t - (abs(next_x - x) + abs(next_y - y)), 2) == 1,
do: {:halt, [next_t, next_x, next_y, "No"]}
defp do_solve([next_t, next_x, next_y], _),
do: {:cont, [next_t, next_x, next_y, "Yes"]}
end
Submission Info
| Submission Time |
|
| Task |
ABC086C - Traveling |
| User |
awesomey |
| Language |
Elixir (1.10.2) |
| Score |
300 |
| Code Size |
1268 Byte |
| Status |
AC |
| Exec Time |
909 ms |
| Memory |
57004 KiB |
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
300 / 300 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
0_000.txt, 0_001.txt, 0_002.txt |
| All |
0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, after_contest_01.txt |
| Case Name |
Status |
Exec Time |
Memory |
| 0_000.txt |
AC |
405 ms |
30664 KiB |
| 0_001.txt |
AC |
430 ms |
30572 KiB |
| 0_002.txt |
AC |
386 ms |
30464 KiB |
| 1_003.txt |
AC |
393 ms |
30408 KiB |
| 1_004.txt |
AC |
895 ms |
56564 KiB |
| 1_005.txt |
AC |
888 ms |
51400 KiB |
| 1_006.txt |
AC |
909 ms |
57004 KiB |
| 1_007.txt |
AC |
477 ms |
33932 KiB |
| 1_008.txt |
AC |
398 ms |
30556 KiB |
| 1_009.txt |
AC |
501 ms |
34504 KiB |
| 1_010.txt |
AC |
393 ms |
30568 KiB |
| 1_011.txt |
AC |
463 ms |
32828 KiB |
| 1_012.txt |
AC |
397 ms |
30528 KiB |
| after_contest_01.txt |
AC |
354 ms |
30628 KiB |