結果
問題 | No.2427 Tree Distance Two |
ユーザー | kotatsugame |
提出日時 | 2023-08-18 21:05:01 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 190 ms / 2,000 ms |
コード長 | 385 bytes |
コンパイル時間 | 631 ms |
コンパイル使用メモリ | 72,192 KB |
実行使用メモリ | 24,192 KB |
最終ジャッジ日時 | 2024-11-28 04:45:05 |
合計ジャッジ時間 | 5,821 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 35 |
ソースコード
#include<iostream> #include<algorithm> #include<vector> #include<cassert> using namespace std; int N; vector<int>G[3<<17]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin>>N; for(int i=1;i<N;i++) { int u,v;cin>>u>>v; G[u].push_back(v); G[v].push_back(u); } for(int i=1;i<=N;i++) { int ans=0; for(int v:G[i])ans+=G[v].size()-1; cout<<ans<<"\n"; } }