結果

問題 No.2427 Tree Distance Two
ユーザー tomeruntomerun
提出日時 2023-08-18 21:11:41
言語 Crystal
(1.11.2)
結果
AC  
実行時間 234 ms / 2,000 ms
コード長 278 bytes
コンパイル時間 15,414 ms
コンパイル使用メモリ 254,856 KB
実行使用メモリ 55,568 KB
最終ジャッジ日時 2023-08-18 21:12:08
合計ジャッジ時間 21,123 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,432 KB
testcase_01 AC 2 ms
4,392 KB
testcase_02 AC 2 ms
4,520 KB
testcase_03 AC 232 ms
37,936 KB
testcase_04 AC 2 ms
4,432 KB
testcase_05 AC 226 ms
37,960 KB
testcase_06 AC 2 ms
4,576 KB
testcase_07 AC 197 ms
55,568 KB
testcase_08 AC 199 ms
40,020 KB
testcase_09 AC 181 ms
52,500 KB
testcase_10 AC 234 ms
40,692 KB
testcase_11 AC 182 ms
52,020 KB
testcase_12 AC 197 ms
53,236 KB
testcase_13 AC 213 ms
51,264 KB
testcase_14 AC 125 ms
38,336 KB
testcase_15 AC 2 ms
4,556 KB
testcase_16 AC 2 ms
4,528 KB
testcase_17 AC 2 ms
4,436 KB
testcase_18 AC 2 ms
4,400 KB
testcase_19 AC 2 ms
4,384 KB
testcase_20 AC 6 ms
5,924 KB
testcase_21 AC 7 ms
5,952 KB
testcase_22 AC 3 ms
4,888 KB
testcase_23 AC 3 ms
4,952 KB
testcase_24 AC 7 ms
6,012 KB
testcase_25 AC 68 ms
13,272 KB
testcase_26 AC 124 ms
26,852 KB
testcase_27 AC 88 ms
22,584 KB
testcase_28 AC 228 ms
36,340 KB
testcase_29 AC 207 ms
32,600 KB
testcase_30 AC 121 ms
26,680 KB
testcase_31 AC 71 ms
20,344 KB
testcase_32 AC 117 ms
26,384 KB
testcase_33 AC 104 ms
23,884 KB
testcase_34 AC 28 ms
11,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = read_line.to_i
g = Array.new(n) { [] of Int32 }
(n - 1).times do
  u, v = read_line.split.map { |v| v.to_i - 1 }
  g[u] << v
  g[v] << u
end
dist1 = Array.new(n) { |i| g[i].size }
dist2 = Array.new(n) do |i|
  g[i].sum { |j| dist1[j] } - g[i].size
end
puts dist2.join("\n")
0