题解
代码
1 #include <cstdio>
2 #include <iostream>
3 #define N 210
4 using namespace std;
5 int n,m,cnt,w[N],f[N][N],ans[N];
6 void dfs(int x)
7 {
8 for (int i=1;i<=n;i++) if (f[x][i]) f[x][i]--,f[i][x]--,dfs(i);
9 ans[++cnt]=x;
10 }
11 int main()
12 {
13 scanf("%d%d",&n,&m);
14 for (int i=1;i<=n;i++) scanf("%d",&w[i]);
15 for (int i=1,x,y;i<=m;i++) scanf("%d%d",&x,&y),f[x][y]++,f[y][x]++;
16 dfs(1),printf("%d\n",cnt-1);
17 for (int i=cnt;i>=1;i--) printf("%d ",ans[i]);
18 }
标签:小路,村子,Jzoj,邮局,整数,int,邮递员,P1319
来源: https://www.cnblogs.com/Comfortable/p/10473074.html