这真的没有什么好讲的,直接看代码吧。
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
const int N = 1e4 + 10, M = 5e4 + 10;
int n, m, siz, path[M << 1];
int tot, Head[N], Edge[M << 1], Next[M << 1];
void add(int x, int y) {
tot++;
Edge[tot] = y;
Next[tot] = Head[x];
Head[x] = tot;
}
void dfs(int x) {
for (int i = Head[x]; i; i = Head[x]) {
int y = Edge[i]; Head[x] = Next[i];
dfs(y);
}
path[++siz] = x;
}
int main() {
cin >> n >> m;
for (int i = 1; i <= m; i++) {
int x, y; scanf("%d%d", &x, &y);
add(x, y), add(y, x);
}
dfs(1);
for (int i = siz; i >= 1; i--) printf("%d\n", path[i]);
return 0;
}
您好,如果每条边只允许被便利一次,然后求一条欧拉回路,我该怎么求呢?麻烦您讲讲
把反边标记一下就好,st[j^1]=1;
您好,能给一个代码吗?我调了好久了,一直不对qaq
https://www.acwing.com/problem/content/submission/code_detail/2551305/你看看这个题
404了
1184那个题
那个题是输出边的编号,我想整个输出点的序号板子,请问您有吗