uva10004 Bicoloring 二分图染色

#include 
#include 
#include 
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

你可能感兴趣的:(二分图)