fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Ideone
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. Scanner in = new Scanner(System.in);
  10. int m,n,f,l;
  11. boolean p=true;
  12. n=in.nextInt();
  13. m=in.nextInt();
  14. int[] a = new int[n];
  15. for (int i=0; i<m; i++){
  16. f=in.nextInt();
  17. l=in.nextInt();
  18. a[f-1]++; a[l-1]++;
  19. }
  20. for (int i=0; i<n; i++){if (a[i]!=a[0]){p=false; break;}}
  21. if (p) System.out.println("YES");
  22. else System.out.println("NO");
  23. }
  24. }
Success #stdin #stdout 0.16s 321344KB
stdin
3 3
1 2
1 3
2 3
stdout
YES