题目描述
blablabla
C++ 代码
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,m,x,y;
cin>>n>>m;
vector<int> a[n+1];
int b[n+1]={0};
while(m--)
{
cin>>x>>y;
a[x].push_back(y);
a[y].push_back(x);
}
b[1]=1;
queue<int>p;
p.push(1);
while(!p.empty())
{
int t=p.front();
p.pop();
int k=b[t]%2+1;
for(int i=0;i<a[t].size();i++)
{
int s=a[t][i];
if(b[s]==0)
{
b[s]=k;
p.push(s);
}
else if(b[s]!=k)
{
cout<<"No"<<endl;
return 0;
}
}
}
cout<<"Yes"<<endl;
return 0;
}