#include <iostream>
#include <queue>
#include <memory.h>
using namespace std;
int color[1005];
int main()
{
int n,m;
while(cin >> n >> m && n != 0)
{
vector<int> g[1005];
int a,b;
for(int i = 0;i < m;i++)
{
cin >> a >> b;
g[a].push_back(b);
g[b].push_back(a);
}
memset(color,0,sizeof(color));
color[1] = 1;
queue<int> q;
q.push(1);
while(!q.empty())
{
int temp = q.front();
q.pop();
for(int i = 0;i < g[temp].size();i++)
{
if(color[temp] == color[g[temp][i]])
{
cout << "no" << endl;
return 0;
}
if(color[g[temp][i]] == 0)
{
color[g[temp][i]] = -color[temp];
q.push(g[temp][i]);
}
}
}
cout << "yes" << endl;
}
return 0;
}
sicily. bicoloring
最新推荐文章于 2017-09-16 21:42:27 发布