1 #include <algorithm>
2 #include <cstring>
3 #include <cstdio>
4 #include <queue>
5
6 using namespace std;
7
8 const int N(100005);
9 queue<int>que;
10 int col[N];
11 int n,m,u,v;
12 int head[N],sumedge;
13 struct Edge
14 {
15 int to,next;
16 Edge(int to=0,int next=0) :
17 to(to),next(next){}
18 }edge[N<<1];
19
20 void ins(int from,int to)
21 {
22 edge[++sumedge]=Edge(to,head[from]);
23 head[from]=sumedge;
24 }
25
26 int main()
27 {
28 scanf("%d%d",&n,&m);
29 for(;m;m--)
30 {
31 scanf("%d%d",&u,&v);
32 ins(u,v); ins(v,u);
33 }
34 memset(col,-1,sizeof(col));
35 que.push(1);
36 col[1]=0;
37 while(!que.empty())
38 {
39 int x=que.front();
40 que.pop();
41 for(int i=head[x];i;i=edge[i].next)
42 { v=edge[i].to;
43 if(col[v]!=-1)
44 {
45 if(col[v]==col[x])
46 {
47 printf("Wrong!
");
48 return 0;
49 }
50 }
51 else
52 {
53 col[v]=col[x]^1;
54 que.push(v);;
55 }
56 }
57 }
58 printf("YES!
");
59 return 0;
60 }