結果

問題 No.2427 Tree Distance Two
ユーザー tomeruntomerun
提出日時 2023-08-18 21:11:41
言語 Crystal
(1.11.2)
結果
AC  
実行時間 266 ms / 2,000 ms
コード長 278 bytes
コンパイル時間 10,353 ms
コンパイル使用メモリ 293,840 KB
実行使用メモリ 54,400 KB
最終ジャッジ日時 2024-05-06 02:49:44
合計ジャッジ時間 16,125 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 1 ms
5,248 KB
testcase_03 AC 246 ms
36,992 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 266 ms
36,864 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 217 ms
54,400 KB
testcase_08 AC 227 ms
45,184 KB
testcase_09 AC 203 ms
53,760 KB
testcase_10 AC 230 ms
39,424 KB
testcase_11 AC 216 ms
53,248 KB
testcase_12 AC 225 ms
53,632 KB
testcase_13 AC 224 ms
53,504 KB
testcase_14 AC 145 ms
34,176 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 7 ms
5,376 KB
testcase_21 AC 7 ms
5,376 KB
testcase_22 AC 3 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 6 ms
5,376 KB
testcase_25 AC 49 ms
12,416 KB
testcase_26 AC 129 ms
22,784 KB
testcase_27 AC 87 ms
17,920 KB
testcase_28 AC 246 ms
34,304 KB
testcase_29 AC 188 ms
28,416 KB
testcase_30 AC 125 ms
22,272 KB
testcase_31 AC 72 ms
15,872 KB
testcase_32 AC 121 ms
22,016 KB
testcase_33 AC 104 ms
20,224 KB
testcase_34 AC 30 ms
9,344 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