結果
問題 | No.806 木を道に |
ユーザー |
|
提出日時 | 2020-04-10 16:33:18 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 82 ms / 2,000 ms |
コード長 | 568 bytes |
コンパイル時間 | 1,757 ms |
コンパイル使用メモリ | 170,996 KB |
実行使用メモリ | 8,952 KB |
最終ジャッジ日時 | 2024-09-15 04:46:12 |
合計ジャッジ時間 | 3,670 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 27 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<n;i++) using namespace std; using ll = long long ; using P = pair<ll,ll> ; const ll INF = 1e18; const int MOD = 1000000007; int n = 100005; vector<vector<int>> tree(n,vector<int>()); int main(){ cin >> n; rep(i,n-1){ int a,b; cin >> a >> b; --a;--b; tree[a].push_back(b); tree[b].push_back(a); } int ans = 0; rep(i,n){ if(tree[i].size() == 1) continue; else ans += tree[i].size() - 2; } cout << ans << endl; return 0; }