結果
問題 |
No.806 木を道に
|
ユーザー |
|
提出日時 | 2020-09-10 17:20:40 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 30 ms / 2,000 ms |
コード長 | 718 bytes |
コンパイル時間 | 1,459 ms |
コンパイル使用メモリ | 170,696 KB |
実行使用メモリ | 8,920 KB |
最終ジャッジ日時 | 2024-12-23 13:46:13 |
合計ジャッジ時間 | 2,880 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 27 |
ソースコード
#include <algorithm> #include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rrep(i, n) for (int i = (int)n - 1; i > -1; i--) #define all(x) (x).begin(), (x).end() #define ll long long #define ld long double #define INF 1000000000000000000 typedef pair<ll, ll> pll; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vector<vector<int>> G(N, vector<int>()); rep(i, N - 1) { int a, b; cin >> a >> b; a--, b--; G[a].push_back(b); G[b].push_back(a); } int cnt = 0; rep(i, N) { if (G[i].size() == 1) cnt++; } cout << max(0, cnt - 2) << endl; }