Submission #677288

#TimeUsernameProblemLanguageResultExecution timeMemory
677288AriadnaSenior Postmen (BOI14_postmen)C++14
0 / 100
1 ms300 KiB
#include <bits/stdc++.h> using namespace std; int n, m; vector < vector < int > > adj; vector < vector < int > > tours; vector < vector < bool > > visited; void tour(int u, int s, vector < int >& aux, int streets) { aux.push_back(u); cout << u << " " << s << '\n'; for (auto v : adj[u]) { if (v == s && streets == m - 1) { tours.push_back(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 (vector < int > i : tours) { for (int j : i) cout << j + 1 << " "; cout << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...