結果

問題 No.870 無敵囲い
ユーザー gemmarogemmaro
提出日時 2020-04-19 17:10:50
言語 Elixir
(1.16.2)
結果
TLE  
実行時間 -
コード長 737 bytes
コンパイル時間 2,512 ms
コンパイル使用メモリ 54,832 KB
実行使用メモリ 51,308 KB
最終ジャッジ日時 2023-09-11 16:32:44
合計ジャッジ時間 15,412 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 TLE -
testcase_02 TLE -
testcase_03 TLE -
testcase_04 TLE -
testcase_05 TLE -
testcase_06 TLE -
testcase_07 TLE -
testcase_08 TLE -
testcase_09 TLE -
testcase_10 TLE -
testcase_11 TLE -
testcase_12 TLE -
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

defmodule Main do
  def main do
    1..(IO.read(:line)
        |> String.trim()
        |> String.to_integer())
    |> Enum.map(fn _ ->
      IO.read(:line)
      |> String.trim()
      |> String.split()
      |> Enum.map(&String.to_integer/1)
    end)
    |> solve
    |> IO.puts()
  end

  def solve(x) do
    solve_rec(x, {{2, 8}, {3, 9}, {7, 9}})
  end

  def solve_rec([], {a, b, c}) do
    cond do
      a == {5, 8} && b == {4, 8} && c == {6, 8} -> "YES"
      true -> "NO"
    end
  end

  def solve_rec([[x1, y1, x2, y2] | t], {a, b, c}) do
    solve_rec(
      t,
      case {x1, y1} do
        ^a -> {{x2, y2}, b, c}
        ^b -> {a, {x2, y2}, c}
        ^c -> {a, b, {x2, y2}}
        _ -> {a, b, c}
      end
    )
  end
end
0