Submission #891948

# Submission time Handle Problem Language Result Execution time Memory
891948 2023-12-24T13:44:33 Z HaciyevAlik Senior Postmen (BOI14_postmen) C++14
0 / 100
2 ms 4956 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mx=2e5+5;
vector<pair<int,int>> g[mx],edges;
bool used[mx];
int n,m;
vector<int> path;
void dfs(int u) {
    while(!g[u].empty()) {
        pair<int,int> cur = g[u].back();
        g[u].pop_back();
        if(used[cur.second]) continue;
        used[cur.second] = true;
        dfs(cur.first);
    }
    path.push_back(u);
}
int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);    
    cin >> n >> m;
    for(int i=1;i<=m;++i) {
        int u,v; cin >> u >> v;
        edges.push_back({u,v});
        g[u].push_back({v,i});
        g[v].push_back({u,i});
    }
    for(int i=0;i<m;++i) {
        if(!used[i+1]) {
            dfs(edges[i].first);
            for(auto j:path) {
                cout << j << " ";
            }
            path.clear();
            cout << '\n';
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4952 KB Same junction appears twice in a route
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4952 KB Same junction appears twice in a route
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4956 KB Same junction appears twice in a route
2 Halted 0 ms 0 KB -