Submission #677288

# Submission time Handle Problem Language Result Execution time Memory
677288 2023-01-02T17:55:31 Z Ariadna Senior Postmen (BOI14_postmen) C++14
0 / 100
1 ms 300 KB
#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 time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 292 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 300 KB Output isn't correct
2 Halted 0 ms 0 KB -