結果
問題 | No.2427 Tree Distance Two |
ユーザー |
|
提出日時 | 2023-08-18 21:20:51 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 191 ms / 2,000 ms |
コード長 | 485 bytes |
コンパイル時間 | 2,487 ms |
コンパイル使用メモリ | 247,896 KB |
実行使用メモリ | 21,760 KB |
最終ジャッジ日時 | 2024-11-28 05:28:18 |
合計ジャッジ時間 | 7,315 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 35 |
ソースコード
#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';}}