結果

問題 No.806 木を道に
ユーザー gemmarogemmaro
提出日時 2020-04-25 19:49:55
言語 Elixir
(1.16.2)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 553 bytes
コンパイル時間 1,610 ms
コンパイル使用メモリ 54,424 KB
実行使用メモリ 116,844 KB
最終ジャッジ日時 2023-08-30 00:43:30
合計ジャッジ時間 39,626 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 613 ms
50,536 KB
testcase_01 AC 600 ms
49,524 KB
testcase_02 AC 613 ms
49,272 KB
testcase_03 AC 606 ms
49,552 KB
testcase_04 AC 613 ms
49,236 KB
testcase_05 AC 628 ms
49,956 KB
testcase_06 AC 610 ms
49,900 KB
testcase_07 AC 615 ms
49,968 KB
testcase_08 AC 634 ms
50,012 KB
testcase_09 AC 629 ms
49,704 KB
testcase_10 AC 947 ms
60,816 KB
testcase_11 AC 920 ms
61,748 KB
testcase_12 AC 1,936 ms
98,572 KB
testcase_13 AC 1,578 ms
84,068 KB
testcase_14 AC 1,840 ms
97,664 KB
testcase_15 AC 1,945 ms
98,460 KB
testcase_16 AC 1,059 ms
70,328 KB
testcase_17 AC 1,773 ms
94,616 KB
testcase_18 AC 740 ms
52,856 KB
testcase_19 AC 971 ms
61,360 KB
testcase_20 AC 1,770 ms
93,720 KB
testcase_21 AC 1,247 ms
71,744 KB
testcase_22 TLE -
testcase_23 TLE -
testcase_24 AC 1,415 ms
74,108 KB
testcase_25 AC 1,821 ms
94,880 KB
testcase_26 AC 1,055 ms
62,264 KB
testcase_27 TLE -
testcase_28 AC 664 ms
50,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

  def solve(a) do
    a
    |> Enum.reduce(
      %{},
      fn [x, y], acc ->
        acc
        |> Map.update(x, [y], &[y | &1])
        |> Map.update(y, [x], &[x | &1])
      end
    )
    |> Enum.map(fn {_, v} -> max((v |> length) - 2, 0) end)
    |> Enum.sum()
  end
end
0