标签:des style color os io for ar div
3 3 1 2 1 3 2 3 3 2 1 2 2 3 0
1 0
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<limits.h> using namespace std; const int maxn=1100; int d[maxn]; int pre[maxn]; int n,m; void init() { memset(d,0,sizeof(d)); for(int i=0;i<=n;i++) pre[i]=i; } int find_root(int x) { if(x!=pre[x]) pre[x]=find_root(pre[x]); return pre[x]; } bool ok() { int x=-1; for(int i=0;i<=n;i++) { if(d[i]&1) return false;; if(d[i]) { if(x==-1) x=find_root(i); else { if(x!=find_root(i)) return false; } } } return true; } int main() { int x,y; while(~scanf("%d",&n)) { if(n==0) break; scanf("%d",&m); init(); for(int i=0;i<m;i++) { scanf("%d%d",&x,&y); d[x]++; d[y]++;; pre[find_root(x)]=find_root(y); } if(!ok()) cout<<0<<endl; else cout<<1<<endl; } return 0; }
标签:des style color os io for ar div
原文地址:http://blog.csdn.net/u013582254/article/details/38510785