結果
問題 | No.2427 Tree Distance Two |
ユーザー |
|
提出日時 | 2024-11-13 21:32:43 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 372 ms / 2,000 ms |
コード長 | 569 bytes |
コンパイル時間 | 3,039 ms |
コンパイル使用メモリ | 249,092 KB |
実行使用メモリ | 21,968 KB |
最終ジャッジ日時 | 2024-11-13 21:32:56 |
合計ジャッジ時間 | 12,356 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 35 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;#define rep(i, s, e) for (int i = (int)s; i < (int)e; ++i)#define all(a) (a).begin(),(a).end()int main() {cin.tie(nullptr);int N;cin >> N;vector<vector<int>> G(N, vector<int>());rep(i, 0, N - 1) {int u, v;cin >> u >> v;u--, v--;G[u].push_back(v);G[v].push_back(u);}rep(i, 0, N) {int ans = 0;for (int next : G[i]) ans += G[next].size() - 1;cout << ans << '\n';}}