結果

問題 No.2427 Tree Distance Two
ユーザー Today03Today03
提出日時 2023-08-18 22:26:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 763 ms / 2,000 ms
コード長 391 bytes
コンパイル時間 2,037 ms
コンパイル使用メモリ 203,400 KB
実行使用メモリ 21,888 KB
最終ジャッジ日時 2024-05-06 04:43:59
合計ジャッジ時間 15,734 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 726 ms
19,968 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 763 ms
20,096 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 632 ms
20,936 KB
testcase_08 AC 669 ms
21,888 KB
testcase_09 AC 652 ms
20,864 KB
testcase_10 AC 688 ms
21,248 KB
testcase_11 AC 675 ms
21,480 KB
testcase_12 AC 689 ms
20,408 KB
testcase_13 AC 698 ms
20,224 KB
testcase_14 AC 566 ms
19,584 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 16 ms
5,376 KB
testcase_21 AC 18 ms
5,376 KB
testcase_22 AC 6 ms
5,376 KB
testcase_23 AC 4 ms
5,376 KB
testcase_24 AC 15 ms
5,376 KB
testcase_25 AC 157 ms
7,552 KB
testcase_26 AC 429 ms
13,568 KB
testcase_27 AC 321 ms
10,624 KB
testcase_28 AC 701 ms
18,688 KB
testcase_29 AC 572 ms
16,896 KB
testcase_30 AC 417 ms
13,312 KB
testcase_31 AC 268 ms
9,856 KB
testcase_32 AC 423 ms
13,184 KB
testcase_33 AC 357 ms
12,032 KB
testcase_34 AC 99 ms
6,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<vector<int>> g(n);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (int i = 0; i < n; i++) {
    int ans = 0;
    for (int nxt : g[i]) {
      ans += g[nxt].size() - 1;
    }
    cout << ans << endl;
  }
}
0