結果

問題 No.806 木を道に
ユーザー TANIGUCHI KousukeTANIGUCHI Kousuke
提出日時 2019-12-17 13:15:08
言語 Ruby
(3.3.0)
結果
AC  
実行時間 221 ms / 2,000 ms
コード長 240 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 11,260 KB
実行使用メモリ 16,188 KB
最終ジャッジ日時 2023-09-15 19:35:03
合計ジャッジ時間 5,578 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
15,136 KB
testcase_01 AC 77 ms
15,108 KB
testcase_02 AC 78 ms
15,120 KB
testcase_03 AC 83 ms
15,064 KB
testcase_04 AC 79 ms
15,136 KB
testcase_05 AC 79 ms
15,252 KB
testcase_06 AC 79 ms
15,072 KB
testcase_07 AC 80 ms
15,120 KB
testcase_08 AC 82 ms
15,256 KB
testcase_09 AC 82 ms
15,124 KB
testcase_10 AC 113 ms
15,316 KB
testcase_11 AC 108 ms
15,484 KB
testcase_12 AC 196 ms
15,992 KB
testcase_13 AC 166 ms
15,660 KB
testcase_14 AC 191 ms
15,860 KB
testcase_15 AC 202 ms
15,916 KB
testcase_16 AC 123 ms
15,560 KB
testcase_17 AC 177 ms
15,980 KB
testcase_18 AC 91 ms
15,252 KB
testcase_19 AC 112 ms
15,316 KB
testcase_20 AC 178 ms
15,912 KB
testcase_21 AC 143 ms
15,732 KB
testcase_22 AC 221 ms
16,188 KB
testcase_23 AC 216 ms
16,152 KB
testcase_24 AC 147 ms
15,684 KB
testcase_25 AC 185 ms
16,024 KB
testcase_26 AC 122 ms
15,412 KB
testcase_27 AC 209 ms
15,904 KB
testcase_28 AC 88 ms
15,252 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

# 道には次数1(葉)の頂点は2つだけ
# 与えられた木の葉の数 - 2がもとめる答え

N = gets.to_i
D = Array.new(N + 1, 0)
(1 ... N).each do
  a,b = gets.split.map(&:to_i)
  D[a] += 1
  D[b] += 1
end
puts D.count(1) - 2
0