Submission #31522

#TimeUsernameProblemLanguageResultExecution timeMemory
31522minhtung0404Senior Postmen (BOI14_postmen)C++14
55 / 100
971 ms141244 KiB
#include<bits/stdc++.h> const int N = 5e5 + 5; using namespace std; typedef pair <int, int> ii; set <int> adj[N]; vector <int> mv[N]; int n, m, a, b, cnt; bool check[N], edge[N]; stack <int> ms; void dfs(int u){ while (adj[u].size()){ int v = *adj[u].begin(); adj[u].erase(adj[u].begin()); adj[v].erase(u); dfs(v); } if (check[u]){ while (ms.top() != u){ cout << ms.top() << " "; check[ms.top()] = 0; ms.pop(); } cout << u << "\n"; ms.pop(); check[u] = 0; } check[u] = 1; ms.push(u); } int main(){ //ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> m; for (int i = 0; i < m; i++) { cin >> a >> b; adj[a].insert(b); adj[b].insert(a); } dfs(1); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...