結果
問題 | No.806 木を道に |
ユーザー |
![]() |
提出日時 | 2019-03-22 21:26:06 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 18 ms / 2,000 ms |
コード長 | 467 bytes |
コンパイル時間 | 1,667 ms |
コンパイル使用メモリ | 167,508 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-19 02:44:47 |
合計ジャッジ時間 | 2,495 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 27 |
ソースコード
#include <bits/stdc++.h> using namespace std; using lint = long long; template<class T = int> using V = vector<T>; template<class T = int> using VV = V< V<T> >; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; V<> d(n); for (int i = 0; i < n - 1; ++i) { int a, b; cin >> a >> b, --a, --b; ++d[a]; ++d[b]; } int cnt = 0; for (int i = 0; i < n; ++i) { cnt += d[i] == 1; } cout << max(cnt - 2, 0) << '\n'; }