結果

問題 No.2427 Tree Distance Two
ユーザー laneguelanegue
提出日時 2023-08-18 21:38:24
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 659 ms / 2,000 ms
コード長 367 bytes
コンパイル時間 3,181 ms
コンパイル使用メモリ 161,252 KB
実行使用メモリ 41,408 KB
最終ジャッジ日時 2023-08-18 21:38:41
合計ジャッジ時間 15,196 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 659 ms
41,292 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 627 ms
41,408 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 612 ms
27,016 KB
testcase_08 AC 585 ms
29,376 KB
testcase_09 AC 608 ms
27,800 KB
testcase_10 AC 579 ms
28,052 KB
testcase_11 AC 600 ms
28,132 KB
testcase_12 AC 587 ms
28,324 KB
testcase_13 AC 614 ms
39,592 KB
testcase_14 AC 485 ms
27,304 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 14 ms
4,544 KB
testcase_21 AC 16 ms
4,540 KB
testcase_22 AC 5 ms
4,380 KB
testcase_23 AC 4 ms
4,376 KB
testcase_24 AC 14 ms
4,540 KB
testcase_25 AC 142 ms
17,572 KB
testcase_26 AC 369 ms
25,280 KB
testcase_27 AC 261 ms
24,100 KB
testcase_28 AC 609 ms
41,180 KB
testcase_29 AC 529 ms
38,632 KB
testcase_30 AC 387 ms
25,484 KB
testcase_31 AC 228 ms
19,876 KB
testcase_32 AC 359 ms
25,756 KB
testcase_33 AC 337 ms
25,704 KB
testcase_34 AC 89 ms
12,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;
void main(){
  int n = readln.chomp.to!int;
  auto e = new int[][n];
  for(auto i = 0; i < n - 1; i++){
    auto input = readln.chomp.split.to!(int[]);
    e[input[0] - 1] ~= input[1] - 1;
    e[input[1] - 1] ~= input[0] - 1;
  }
  for(auto i = 0; i < n; i++){
    auto s = 0;
    foreach(j; e[i]){
      s += e[j].length - 1;
    }
    writeln(s);
  }
}
0