結果

問題 No.2427 Tree Distance Two
ユーザー 0214sh70214sh7
提出日時 2023-08-17 23:31:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 645 ms / 2,000 ms
コード長 641 bytes
コンパイル時間 2,308 ms
コンパイル使用メモリ 204,780 KB
実行使用メモリ 26,368 KB
最終ジャッジ日時 2024-05-05 06:19:00
合計ジャッジ時間 15,623 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,248 KB
testcase_03 AC 635 ms
23,808 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 642 ms
23,808 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 610 ms
24,392 KB
testcase_08 AC 606 ms
26,368 KB
testcase_09 AC 593 ms
24,320 KB
testcase_10 AC 599 ms
25,088 KB
testcase_11 AC 598 ms
24,080 KB
testcase_12 AC 645 ms
23,944 KB
testcase_13 AC 597 ms
23,836 KB
testcase_14 AC 527 ms
22,144 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 1 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 15 ms
5,376 KB
testcase_21 AC 18 ms
5,376 KB
testcase_22 AC 5 ms
5,376 KB
testcase_23 AC 4 ms
5,376 KB
testcase_24 AC 16 ms
5,376 KB
testcase_25 AC 148 ms
8,576 KB
testcase_26 AC 381 ms
16,000 KB
testcase_27 AC 260 ms
12,416 KB
testcase_28 AC 591 ms
22,400 KB
testcase_29 AC 510 ms
19,968 KB
testcase_30 AC 354 ms
15,744 KB
testcase_31 AC 220 ms
11,264 KB
testcase_32 AC 354 ms
15,488 KB
testcase_33 AC 333 ms
14,080 KB
testcase_34 AC 107 ms
6,656 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;
const long long INF = (1ll<<61)-1;

int main(void){
    //cin.tie(nullptr);
    //ios::sync_with_stdio(false);
    
    long long N;
    cin >> N;
    vector<vector<long long>> G(N);
    for(int i=0;i<N-1;i++){
        long long u,v;
        cin >> u >> v;
        u--;v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }

    vector<long long> Ans(N,0);

    for(int i=0;i<N;i++){
        for(long long e:G[i]){
            Ans[e] += -1+G[i].size();
        }
    }

    for(int i=0;i<N;i++){
        cout << Ans[i] << endl;
    }


    return 0;
}
0