Pagini recente » Cod sursa (job #2715164) | Cod sursa (job #1459854) | Monitorul de evaluare | Cod sursa (job #3241721) | Cod sursa (job #2171636)
#include<bits/stdc++.h>
using namespace std;
int N,M,x,y;
vector <int> G[100001],st;
int main()
{
freopen("ciclueuler.in","r",stdin);
freopen("ciclueuler.out","w",stdout);
scanf("%d%d",&N,&M);
while(M--){
scanf("%d%d",&x,&y);
G[x].push_back(y);
G[y].push_back(x);
}
st.push_back(1);
while(!st.empty()){
int nod=st.back();
if(G[nod].size()){
y=G[nod].back();
G[nod].pop_back();
G[y].erase(find(G[y].begin(),G[y].end(),nod));
st.push_back(y);
}else{
printf("%d ",nod);
st.pop_back();
}
}
return 0;
}