Submission #998894

#TimeUsernameProblemLanguageResultExecution timeMemory
998894lucascgarSenior Postmen (BOI14_postmen)C++17
100 / 100
238 ms64192 KiB
#include<bits/stdc++.h> using namespace std; typedef pair<int, int> pii; typedef pair<long, long> pll; typedef pair<double, double> pdd; /* desde quando vi da ultima vez até quando vejo de novo, deixo ele em ans sozinho */ const int MAXN = 5e5+10; vector<pii> e[MAXN]; vector<int> ans; bool ve[MAXN]; bool v[MAXN]; void dfs(int x){ while (!e[x].empty()){ pii u = e[x].back(); e[x].pop_back(); if (ve[u.second] == 1) continue; ve[u.second] = 1; dfs(u.first); } ans.push_back(x); if (!v[x]) v[x] = 1; else{ ans.pop_back(); cout << x; while (ans.back() != x){ cout << " " << ans.back(); v[ans.back()] = 0; ans.pop_back(); } cout << "\n"; } } int main(){ std::ios_base::sync_with_stdio(false); cin.tie(nullptr); int n, m; cin >> n >> m; int a, b; for (int i=0;i<m;i++){ cin >> a >> b; e[a].emplace_back(b, i); e[b].emplace_back(a, i); } dfs(1); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...