結果

問題 No.2427 Tree Distance Two
ユーザー kuronikuroni
提出日時 2023-08-18 21:20:51
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 228 ms / 2,000 ms
コード長 485 bytes
コンパイル時間 3,377 ms
コンパイル使用メモリ 247,696 KB
実行使用メモリ 21,844 KB
最終ジャッジ日時 2023-08-18 21:21:48
合計ジャッジ時間 8,768 ms
ジャッジサーバーID
(参考情報)
judge10 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 211 ms
19,740 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 228 ms
19,808 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 150 ms
20,848 KB
testcase_08 AC 187 ms
21,844 KB
testcase_09 AC 164 ms
20,708 KB
testcase_10 AC 190 ms
21,112 KB
testcase_11 AC 168 ms
21,484 KB
testcase_12 AC 214 ms
20,376 KB
testcase_13 AC 188 ms
20,096 KB
testcase_14 AC 100 ms
19,536 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,384 KB
testcase_19 AC 1 ms
4,384 KB
testcase_20 AC 5 ms
4,384 KB
testcase_21 AC 5 ms
4,380 KB
testcase_22 AC 2 ms
4,384 KB
testcase_23 AC 2 ms
4,384 KB
testcase_24 AC 5 ms
4,384 KB
testcase_25 AC 35 ms
7,584 KB
testcase_26 AC 107 ms
13,488 KB
testcase_27 AC 65 ms
10,596 KB
testcase_28 AC 186 ms
18,476 KB
testcase_29 AC 152 ms
16,588 KB
testcase_30 AC 98 ms
12,992 KB
testcase_31 AC 56 ms
9,716 KB
testcase_32 AC 95 ms
12,928 KB
testcase_33 AC 80 ms
12,008 KB
testcase_34 AC 22 ms
6,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    vector<vector<int>> adj(n);
    for (int i = 1; i < n; i++) {
        int u, v; cin >> u >> v; u--; v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    for (int u = 0; u < n; u++) {
        int ans = 0;
        for (int v : adj[u]) {
            ans += adj[v].size() - 1;
        }
        cout << ans << '\n';
    }
}
0