fork(1) download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int main() {
  6. int m,n,f,l; bool p=true;
  7. cin>>n>>m;
  8. vector <int> a(n);
  9. for (int i=0; i<m; i++){
  10. cin>>f>>l;
  11. a[f-1]++; a[l-1]++;
  12. }
  13. for (int i=0; i<n; i++){if (a[i]!=a[0]){p=false; break;}}
  14. if (p) cout<<"YES"<<endl;
  15. else cout<<"NO"<<endl;
  16. }
Success #stdin #stdout 0s 3416KB
stdin
3 2
1 2
2 3
stdout
NO