Judge the Euler's loop of an undirected graph, without explanation ,,,,
ACCode:
# Include <iostream> # include <string. h >#include <cstdio> # define CLR (ARR, Val) memset (ARR, Val, sizeof (ARR) # define n 1001 using namespace STD; int deg [N]; int father [N]; void Init (int n) {CLR (deg, 0); For (INT I = 0; I! = N + 1; ++ I) Father [I] = I;} int find (INT X) {If (x = Father [x]) return X; return father [x] = find (father [x]);} void Union (int x, int y) {int A = find (X ); int B = find (y); if (! = B) {FATHER [a] = B ;}} int main () {int n, m; while (~ Scanf ("% d", & N, & M), n) {Init (n); int A, B; For (INT I = 0; I! = M; ++ I) {scanf ("% d", & A, & B); deg [a] ++; deg [B] ++; union (a, B);} int res = 0, ANS = 0; For (INT I = 1; I <= N; ++ I) {If (find (I) = I) RES ++; If (deg [I] & 1) ans ++;} If (RES> 1 | ans) puts ("0 "); else puts ("1");} return 0 ;}