結果

問題 No.2427 Tree Distance Two
ユーザー simansiman
提出日時 2023-08-23 19:08:48
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,156 ms / 2,000 ms
コード長 216 bytes
コンパイル時間 165 ms
コンパイル使用メモリ 11,380 KB
実行使用メモリ 42,772 KB
最終ジャッジ日時 2023-08-23 19:09:15
合計ジャッジ時間 26,554 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
15,236 KB
testcase_01 AC 80 ms
15,132 KB
testcase_02 AC 81 ms
15,236 KB
testcase_03 AC 1,133 ms
42,588 KB
testcase_04 AC 79 ms
15,020 KB
testcase_05 AC 1,156 ms
42,772 KB
testcase_06 AC 79 ms
15,240 KB
testcase_07 AC 985 ms
38,940 KB
testcase_08 AC 1,016 ms
39,788 KB
testcase_09 AC 961 ms
40,172 KB
testcase_10 AC 995 ms
39,920 KB
testcase_11 AC 1,009 ms
38,944 KB
testcase_12 AC 1,042 ms
38,696 KB
testcase_13 AC 1,078 ms
39,148 KB
testcase_14 AC 841 ms
36,692 KB
testcase_15 AC 80 ms
15,272 KB
testcase_16 AC 80 ms
15,092 KB
testcase_17 AC 80 ms
15,236 KB
testcase_18 AC 81 ms
15,168 KB
testcase_19 AC 81 ms
15,148 KB
testcase_20 AC 103 ms
15,736 KB
testcase_21 AC 111 ms
15,892 KB
testcase_22 AC 88 ms
15,504 KB
testcase_23 AC 86 ms
15,148 KB
testcase_24 AC 112 ms
15,724 KB
testcase_25 AC 328 ms
22,832 KB
testcase_26 AC 705 ms
31,584 KB
testcase_27 AC 546 ms
28,136 KB
testcase_28 AC 1,059 ms
42,148 KB
testcase_29 AC 903 ms
38,912 KB
testcase_30 AC 709 ms
31,428 KB
testcase_31 AC 477 ms
24,940 KB
testcase_32 AC 705 ms
31,076 KB
testcase_33 AC 632 ms
30,592 KB
testcase_34 AC 232 ms
19,740 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
G = Array.new(N + 1) { [] }

(N - 1).times do
  u, v = gets.split.map(&:to_i)

  G[u] << v
  G[v] << u
end

1.upto(N) do |u|
  cnt = 0

  G[u].each do |v|
    cnt += G[v].size - 1
  end

  puts cnt
end
0