#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
const int N=500;
const int M=40000;
struct List{
int v;
List *next;
}pool[M],*c[N],*pp;
int n,m;
int col[N];
bool flag;
inline void add_edge(int u,int v,List *c[]){
pp->v=v;
pp->next=c[u];
c[u]=pp++;
}
void dfs(int u){
for(List *p=c[u];p ;p=p -> next){
int v=p->v;
if(col[u]&&!col[v]){
if(col[u]==1)col[v]=2;
else col[v]=1;
dfs(v);
}
if(col[u]==col[v]){
flag=true;
return ;
}
}
}
int main(){
while(scanf("%d",&n), n){
memset(c,0,sizeof(c));
memset(col,0,sizeof(col));
pp=pool;
flag=false;
scanf("%d",&m);
for(int i=0,a,b;i<m;i++){
scanf("%d%d",&a,&b);
add_edge(a,b,c);
add_edge(b,a,c);
}
col[0]=1;
dfs(0);
if(flag)cout<<"NOT BICOLORABLE."<<endl;
else cout<<"BICOLORABLE."<<endl;
}
return 0;
}
uva10004 Bicoloring 二分图染色
最新推荐文章于 2018-11-30 18:31:00 发布