#include <set>
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
int n,m;
while(scanf("%d%d",&n,&m)!=EOF && n!=-1 && m!=-1)
{
set <int > R_num;
set <int > B_num;
for(int i=1; i<=m; i++)
{
int x,y;
scanf("%d%d",&x,&y);
if(i%2!=0)
{
R_num.insert(x);
R_num.insert(y);
if(B_num.find(x)!=B_num.end() )
B_num.erase(x);
if(B_num.find(y)!=B_num.end() )
B_num.erase(y);
}
else
{
B_num.insert(x);
B_num.insert(y);
if(R_num.find(x)!=R_num.end() )
R_num.erase(x);
if(R_num.find(y)!=R_num.end() )
R_num.erase(y);
}
}
if(B_num.size()==n)
printf("YES\n");
else
printf("NO\n");
set<int >::iterator iter;
for(iter=R_num.begin(); iter!=R_num.end(); iter++)
cout << *iter << endl;
}
return 0;
}
附件列表
时间: 2024-10-07 10:14:57