标签:mat cin ons include cti algorithm algo const mes
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<ctime>
#include<stack>
using namespace std;
const int N=2005;
int n,a,b,G[N][N],d[N],ans[N],Cnt;
void dfs(int x){
for(int i=1;i<=500;i++){
if(G[x][i]){
G[x][i]--;
G[i][x]--;
dfs(i);
}
}
ans[++Cnt]=x;
}
int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>a>>b;
G[a][b]++;
G[b][a]++;
d[a]++;
d[b]++;
}
int s=1;
for(int i=1;i<=500;i++){
if(d[i]%2==1){
s=i;
break;
}
}
dfs(s);
for(int i=n+1;i>=1;i--){
cout<<ans[i]<<endl;
}
return 0;
}
标签:mat cin ons include cti algorithm algo const mes
原文地址:https://www.cnblogs.com/ukcxrtjr/p/11188233.html