結果

問題 No.2427 Tree Distance Two
ユーザー momoyuumomoyuu
提出日時 2023-08-18 21:08:04
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 761 ms / 2,000 ms
コード長 407 bytes
コンパイル時間 2,929 ms
コンパイル使用メモリ 248,720 KB
実行使用メモリ 21,980 KB
最終ジャッジ日時 2024-05-06 02:41:29
合計ジャッジ時間 16,052 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 744 ms
19,956 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 761 ms
19,952 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 685 ms
20,824 KB
testcase_08 AC 698 ms
21,980 KB
testcase_09 AC 699 ms
20,800 KB
testcase_10 AC 690 ms
21,232 KB
testcase_11 AC 695 ms
21,484 KB
testcase_12 AC 745 ms
20,408 KB
testcase_13 AC 719 ms
20,228 KB
testcase_14 AC 593 ms
19,584 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 20 ms
5,376 KB
testcase_22 AC 6 ms
5,376 KB
testcase_23 AC 4 ms
5,376 KB
testcase_24 AC 16 ms
5,376 KB
testcase_25 AC 169 ms
7,680 KB
testcase_26 AC 442 ms
13,684 KB
testcase_27 AC 309 ms
10,752 KB
testcase_28 AC 690 ms
18,856 KB
testcase_29 AC 629 ms
16,896 KB
testcase_30 AC 425 ms
13,412 KB
testcase_31 AC 256 ms
9,728 KB
testcase_32 AC 416 ms
13,160 KB
testcase_33 AC 360 ms
12,032 KB
testcase_34 AC 104 ms
6,016 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