Pagini recente » Cod sursa (job #451921) | Cod sursa (job #24874) | Urmasii lui Moisil 2015, Clasament Clasele 11-12 | Cod sursa (job #106763) | Cod sursa (job #2564990)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("ciclueuler.in");
ofstream fout("ciclueuler.out");
const int nmax = 100005;
int n, m;
vector < int > l[nmax];
vector < int > v;
bitset < nmax > viz[nmax];
void Dfs(int nod)
{
for (int next : l[nod])
{
if (!viz[nod][next])
{
viz[nod][next] = viz[next][nod] = 1;
Dfs(next);
}
}
v.push_back(nod);
}
int main()
{
fin >> n >> m;
for (int i = 1; i <= m; i++)
{
int a, b;
fin >> a >> b;
l[a].push_back(b);
l[b].push_back(a);
}
Dfs(1);
for (int i = 0; i < v.size() - 1; i++)
fout << v[i] << ' ';
fin.close();
fout.close();
return 0;
}