Guest User

Untitled

a guest
Jul 5th, 2019
840
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5.  
  6. int main() {
  7.  
  8. int n;
  9. cin>>n;
  10. vector<int> a(n+1);
  11. int u, v;
  12. for (int i = 0; i<n-1; i++)
  13. {
  14. cin>>u>>v;
  15. a[u]++;
  16. a[v]++;
  17. }
  18. bool check = false;
  19. for (int i = 1; i<=n; i++) if (a[i]==2) check = true;
  20. if (check) cout<<"NO";
  21. else cout<<"YES";
  22. }
RAW Paste Data