結果
問題 | No.806 木を道に |
ユーザー |
![]() |
提出日時 | 2019-03-22 21:29:25 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 50 ms / 2,000 ms |
コード長 | 784 bytes |
コンパイル時間 | 561 ms |
コンパイル使用メモリ | 82,420 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-19 02:50:32 |
合計ジャッジ時間 | 2,079 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 27 |
ソースコード
#include <iostream> #include <vector> #include <string> #include <cmath> #include <algorithm> #include <utility> #include <queue> #include <set> #include <map> #include <deque> #include <iomanip> #include <cstdio> #include <stack> #include <numeric> using namespace std; typedef long long ll; typedef pair<int,int> PII; typedef vector<int> VI; typedef vector<VI> VVI; #define MP make_pair #define PB push_back #define inf 1000000007 #define rep(i,n) for(int i=0;i<(int)(n);++i) int main(){ int n; cin >> n; vector<int>c(n); rep(i,n-1){ int a,b; cin >> a >> b; a--;b--; c[a]++; c[b]++; } int ans = 0; rep(i,n){ if(c[i]==1){ ans++; } } cout << ans-2 << endl; return 0; }