Pagini recente » Cod sursa (job #93077) | Cod sursa (job #703725) | Cod sursa (job #1269384) | Cod sursa (job #1327542) | Cod sursa (job #2673874)
/*
`-/oo+/- ``
.oyhhhhhhyo.`od
+hhhhyyoooos. h/
+hhyso++oosy- /s
.yoooossyyo:``-y`
..----.` ``.-/+:.`
`````..-::/.
`..```.-::///`
`-.....--::::/:
`.......--::////:
`...`....---:::://:
`......``..--:::::///:`
`---.......--:::::////+/`
----------::::::/::///++:
----:---:::::///////////:`
.----::::::////////////:-`
`----::::::::::/::::::::-
`.-----:::::::::::::::-
...----:::::::::/:-`
`.---::/+osss+:`
``.:://///-.
*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cmath>
#define debug(x) cerr << #x << " " << x << "\n"
#define debugsp(x) cerr << #x << " " << x << " "
using namespace std;
const int INF = 2e9;
const int N = 1e5;
const int M = 5e5;
vector <pair <int, int>> G[1 + N];
stack <int> st;
vector <int> sol;
bool viz[1 + M];
int main() {
freopen("ciclueuler.in", "r", stdin);
freopen("ciclueuler.out", "w", stdout);
int n, m;
scanf("%d%d", &n, &m);
for(int i = 1; i <= m; i++) {
int x, y;
scanf("%d%d", &x, &y);
G[x].push_back(make_pair(y, i));
G[y].push_back(make_pair(x, i));
}
st.push(1);
while(st.size()) {
int node = st.top();
if(G[node].size()) {
pair <int, int> to = G[node].back();
G[node].pop_back();
if(!viz[to.second]) {
st.push(to.first);
viz[to.second] = true;
}
} else {
sol.push_back(node);
st.pop();
}
}
for(int i = 0; i < sol.size() - 1; i++)
printf("%d ", sol[i]);
printf("\n");
return 0;
}