#include <cstdio> #include <iostream> #include <string> const int MAX=1000; using namespace std; int father[MAX]; int height[MAX]; void Initialize(int n){ for(int i=0;i<n;i++){ father[i]=i; height[i]=0; } return; } int findRoot(int x){ while(x!=father[x]){ return findRoot(father[x]); } return father[x]; } void Union(int x,int y){ x= findRoot(x); y= findRoot(y); if(x!=y){ if(height[x]< height[y]){ father[x]=y; }else if(height[y]<height[x]){ father[y]=x; }else{ father[y]=x; height[x]++; } } return; } int main(){ int N,M; while(scanf("%d",&N)!=EOF){ Initialize(N); scanf("%d",&M); while(M--){ int x,y; scanf("%d %d",&x,&y); Union(x,y); } int answer=-1; for(int i=0;i<N;i++){ if(father[i]==i){ answer++; } } if(answer<=0){ printf("YES\n"); }else{ printf("NO\n"); } } return 0; }