結果

問題 No.2427 Tree Distance Two
ユーザー take000take000
提出日時 2023-08-18 21:31:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 264 ms / 2,000 ms
コード長 542 bytes
コンパイル時間 2,264 ms
コンパイル使用メモリ 202,912 KB
実行使用メモリ 21,828 KB
最終ジャッジ日時 2023-08-18 21:31:37
合計ジャッジ時間 8,531 ms
ジャッジサーバーID
(参考情報)
judge9 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 264 ms
19,860 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 255 ms
19,676 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 185 ms
20,828 KB
testcase_08 AC 222 ms
21,828 KB
testcase_09 AC 204 ms
20,832 KB
testcase_10 AC 223 ms
21,080 KB
testcase_11 AC 202 ms
21,516 KB
testcase_12 AC 216 ms
20,224 KB
testcase_13 AC 232 ms
20,080 KB
testcase_14 AC 105 ms
19,536 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,384 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 5 ms
4,376 KB
testcase_21 AC 5 ms
4,380 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 AC 2 ms
4,384 KB
testcase_24 AC 4 ms
4,384 KB
testcase_25 AC 48 ms
7,476 KB
testcase_26 AC 143 ms
13,452 KB
testcase_27 AC 97 ms
10,560 KB
testcase_28 AC 240 ms
18,468 KB
testcase_29 AC 204 ms
16,564 KB
testcase_30 AC 142 ms
13,000 KB
testcase_31 AC 85 ms
9,552 KB
testcase_32 AC 141 ms
12,948 KB
testcase_33 AC 127 ms
11,940 KB
testcase_34 AC 27 ms
5,932 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0)->sync_with_stdio(0);

    int N;
    cin >> N;
    vector<vector<int>> G(N);
    rep(i, N - 1) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }

    rep(i, N) {
        int ans = -(int)G[i].size();
        for (int j : G[i]) {
            ans += G[j].size();
        }
        cout << ans << "\n";
    }

    return 0;
}
0