2 条题解
- 
  0
#include <bits/stdc++.h> using namespace std; int maxx,minx=500; int g[501][501]; int degree[501]; int n,u,v; stack<int> ans; int getStart(){ int tot=0; int res=0; for(int i=1;i<=maxx;i++){ if(degree[i]%2==1){ tot++; if(!res)res=i; } } return tot==0||tot==2?res:-1; } void dfs(int pStart){ for(int i=1;i<=maxx;i++){ if(g[pStart][i]>0){ g[pStart][i]--,g[i][pStart]--; dfs(i); } } ans.push(pStart); } int main(){ cin>>n; while(n--){ cin>>u>>v; maxx=max(maxx,max(u,v)); minx=min(minx,min(u,v)); g[u][v]++,g[v][u]++; degree[u]++,degree[v]++; } int pStart=getStart(); if(!pStart)pStart=minx; dfs(pStart); while(!ans.empty()){ cout<<ans.top()<<endl; ans.pop(); } return 0; } 
信息
- ID
 - 596
 - 时间
 - 1000ms
 - 内存
 - 256MiB
 - 难度
 - 8
 - 标签
 - 递交数
 - 161
 - 已通过
 - 23
 - 上传者