#include <bits/stdc++.h>
using namespace std;
int n, m;
vector < int > tours;
vector < vector < int > > adj;
vector < vector < bool > > visited;
void tour(int u, int s, vector < int >& aux, int streets) {
aux.push_back(u);
for (auto v : adj[u]) {
if (v == s && streets == m - 1) {
tours = aux;
} else {
if (!visited[u][v]) {
visited[u][v] = visited[v][u] = true;
tour(v, s, aux, streets + 1);
}
}
}
aux.pop_back();
}
int main()
{
cin >> n >> m;
adj = vector < vector < int > > (n, vector < int >());
visited = vector < vector < bool > > (n, vector < bool >(n, false));
for (int i = 0; i < m; ++i) {
int u, v;
cin >> u >> v;
--u; --v;
adj[u].push_back(v);
adj[v].push_back(u);
}
vector < int > aux;
tour(0, 0, aux, 0);
for (int i : tours)
cout << i + 1 << " ";
cout << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Same junction appears twice in a route |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
296 KB |
Same junction appears twice in a route |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Same junction appears twice in a route |
3 |
Halted |
0 ms |
0 KB |
- |