标签:
#include<stdio.h> #include<string.h> #include<stdlib.h> #include<iostream> #include<algorithm> using namespace std; #define M 210 int num[M]; int findx(int x) { int r = x; while(r!=num[r]) { r = num[r]; } int k = x,j; while(k!=r) { j = num[k]; num[k] = r; k = j; } return r; } void bing(int x,int y) { int fx = findx(x); int fy = findx(y); if(fx!=fy) { num[fx] = fy; } } int main() { int t, k = 1; int v[M]; int n,m; while(scanf("%d%d",&n,&m)!=EOF) { for (int i = 0; i < n; i++) { num[i] = i; v[i] = 0; } for (int i = 0; i < m; i++) { int a, b; scanf("%d%d", &a, &b); v[a]++; v[b]++; bing(a,b); } int cnt = 0; for (int i = 0; i < n; i++) { if (num[i] == i && v[i]!=0) { cnt++; } } int sum = 0; if(cnt == 1 && m>=2) { for(int i=0; i<n; i++) { if(v[i]%2!=0) { sum++; //printf("i = %d\n",i); break; } } if (sum > 0) { printf("Not Possible\n"); } else { printf("Possible\n"); } } else { printf("Not Possible\n"); } } return 0; }
标签:
原文地址:http://blog.csdn.net/yeguxin/article/details/43022001