ThisCodeThe process of finding a small Euler loop and concatenating them to form the Euler loop of the entire graph is realized. I have not figured out why it is correct ...... I think that loop is a key point.
// Read an undirected graph to determine the output loop # include <stdio. h> # define maxn 10010int BL [maxn] [maxn], Match [maxn], path [maxn * 2]; int tot, n, m, X, Y; bool can [maxn] [maxn]; bool check_map () {for (INT I = 1; I <= N; ++ I) if (Match [I] & 1) return 0; return 1;} void find_path (int x) {If (! Match [x]) {path [++ tot] = x; return;} For (INT I = 1; I <= bl [x] [0]; ++ I) {int K = bl [x] [I]; If ((! Match [k]) | (! Can [x] [k]) continue; -- match [X]; -- match [k]; can [x] [k] = Can [k] [x] = 0; find_path (k);} path [++ tot] = x;} int main () {freopen ("sample. in "," r ", stdin); freopen (" sample. out "," W ", stdout); scanf (" % d ", & N, & M); For (INT I = 1; I <= m; ++ I) {scanf ("% d", & X, & Y); BL [x] [++ BL [x] [0] = y; BL [y] [++ BL [y] [0] = x; ++ match [X]; ++ match [y]; can [x] [Y] = Can [y] [x] = 1;} If (! Check_map () {printf ("error! \ N "); Return 0;} find_path (1); For (INT I = 1; I <tot; ++ I) printf (" % D ----> ", path [I]); printf ("% d \ n", path [tot]); Return 0 ;}