結果

問題 No.2427 Tree Distance Two
ユーザー kt_soupkt_soup
提出日時 2023-08-18 21:25:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 761 ms / 2,000 ms
コード長 360 bytes
コンパイル時間 871 ms
コンパイル使用メモリ 71,296 KB
実行使用メモリ 22,016 KB
最終ジャッジ日時 2024-05-06 03:15:01
合計ジャッジ時間 13,840 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 761 ms
20,044 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 745 ms
19,968 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 684 ms
20,808 KB
testcase_08 AC 735 ms
22,016 KB
testcase_09 AC 684 ms
20,864 KB
testcase_10 AC 699 ms
21,236 KB
testcase_11 AC 712 ms
21,440 KB
testcase_12 AC 719 ms
20,408 KB
testcase_13 AC 718 ms
20,224 KB
testcase_14 AC 603 ms
19,572 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 17 ms
5,376 KB
testcase_21 AC 19 ms
5,376 KB
testcase_22 AC 6 ms
5,376 KB
testcase_23 AC 5 ms
5,376 KB
testcase_24 AC 16 ms
5,376 KB
testcase_25 AC 171 ms
7,552 KB
testcase_26 AC 456 ms
13,596 KB
testcase_27 AC 297 ms
10,752 KB
testcase_28 AC 701 ms
18,688 KB
testcase_29 AC 592 ms
16,812 KB
testcase_30 AC 436 ms
13,272 KB
testcase_31 AC 265 ms
9,728 KB
testcase_32 AC 433 ms
13,184 KB
testcase_33 AC 364 ms
12,160 KB
testcase_34 AC 105 ms
6,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
using namespace std;
int main() {
  int N,u,v;
  cin >> N;
  vector<vector<int>> G(N);
  for(int i=1;i<N;i++) {
    cin >> u >> v;
    G[u-1].push_back(v-1);
    G[v-1].push_back(u-1);
  }
  for(int i=0;i<N;i++) {
    int ans = 0;
    for(int j=0;j<G[i].size();j++)ans += G[G[i][j]].size()-1;
    cout << ans << endl;
  }
}
0