fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int v, e;
  6. int degree[3001];
  7.  
  8. cin >> v >> e;
  9. for(int i = 0; i < e; i++){
  10. int a, b;
  11. cin >> a >> b;
  12. degree[a]++;
  13. degree[b]++;
  14. }
  15.  
  16. int cnt = 0;
  17. for(int i = 1; i < v; i++){
  18. if(degree[i] % 2 != 0){
  19. cnt++;
  20. }
  21. }
  22. if(cnt == 0 || cnt == 2) cout << "YES" << endl;
  23. else cout << "NO" << endl;
  24. return 0;
  25. }
Success #stdin #stdout 0.01s 5408KB
stdin
4 5
1 2
1 3
1 4
2 3
2 4
stdout
YES