結果

問題 No.2427 Tree Distance Two
ユーザー momoyuumomoyuu
提出日時 2023-08-18 21:08:04
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 838 ms / 2,000 ms
コード長 407 bytes
コンパイル時間 5,446 ms
コンパイル使用メモリ 246,868 KB
実行使用メモリ 21,664 KB
最終ジャッジ日時 2023-08-18 21:08:40
合計ジャッジ時間 18,449 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 838 ms
19,848 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 814 ms
19,920 KB
testcase_06 AC 1 ms
4,384 KB
testcase_07 AC 713 ms
20,756 KB
testcase_08 AC 734 ms
21,664 KB
testcase_09 AC 732 ms
20,772 KB
testcase_10 AC 721 ms
21,188 KB
testcase_11 AC 743 ms
21,188 KB
testcase_12 AC 740 ms
20,164 KB
testcase_13 AC 772 ms
20,124 KB
testcase_14 AC 580 ms
19,584 KB
testcase_15 AC 2 ms
4,384 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,384 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 16 ms
4,380 KB
testcase_21 AC 20 ms
4,380 KB
testcase_22 AC 6 ms
4,380 KB
testcase_23 AC 4 ms
4,376 KB
testcase_24 AC 16 ms
4,380 KB
testcase_25 AC 179 ms
7,528 KB
testcase_26 AC 471 ms
13,512 KB
testcase_27 AC 320 ms
10,400 KB
testcase_28 AC 714 ms
18,720 KB
testcase_29 AC 642 ms
16,700 KB
testcase_30 AC 459 ms
12,956 KB
testcase_31 AC 283 ms
9,908 KB
testcase_32 AC 477 ms
13,004 KB
testcase_33 AC 390 ms
11,668 KB
testcase_34 AC 108 ms
5,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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++){
        ll ans = 0;
        for(auto&to:g[i]) ans += g[to].size()-1;
        cout<<ans<<endl;
    }
}

0