Submission #677294

#TimeUsernameProblemLanguageResultExecution timeMemory
677294AriadnaSenior Postmen (BOI14_postmen)C++14
0 / 100
1 ms296 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...