1. UNICOM. if the vertex degrees are even, there is an Euler loop. # Include # includeusingnamespacestd; intfather [1010]; intvis [1010] [1010], du [1010]; intfind (intx) {if (father [x] = x)
// 1. Unicom figure 2. if the vertex degrees are even, there is an Euler loop. # Include
# Include
Using namespace std; int father [1010]; int vis [1010] [1010], du [1010]; int find (int x) {if (father [x] = x) return x; return father [x] = find (father [x]);} int main () {int n, m, i, a, B, cot; while (~ Scanf ("% d", & n), n) {for (I = 1; I <= n; I ++) father [I] = I; scanf ("% d", & m); memset (vis, 0, sizeof (vis); memset (du, 0, sizeof (du); while (m --) {scanf ("% d", & a, & B); if (! Vis [a] [B]) {if (a> B) swap (a, B); // small front, ensure that the smallest vis [a] [B] = vis [B] [a] = 1; du [a] ++; du [B] ++; int fa = find (a); int fb = find (B); if (fa! = Fb) {father [fb] = fa ;}} cot = 0; for (I = 1; I <= n; I ++) {if (du [I] % 2 = 0 & find (I) = 1) {cot ++ ;}} if (cot = n) printf ("1 \ n"); else printf ("0 \ n");} return 0 ;}