Submission #1124876

#TimeUsernameProblemLanguageResultExecution timeMemory
1124876TahirAliyevSenior Postmen (BOI14_postmen)C++20
100 / 100
390 ms60708 KiB
#include <bits/stdc++.h> // #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops") // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") // #define int long long #define ld long double #define ll long long #define pii pair<int, int> #define all(v) v.begin(), v.end() using namespace std; const int oo = 1e9 + 9; const int MAX = 5e5 + 6, LOGMAX = 20, B = 400, MOD = 1e9 + 7; int n, m; vector<pii> g[MAX]; int vis[MAX]; vector<int> path; void dfs(int node){ while(g[node].size()){ auto to = g[node].back(); g[node].pop_back(); if(vis[to.second]) continue; vis[to.second] = 1; dfs(to.first); } path.push_back(node); } void solve(){ cin >> n >> m; for(int i = 1; i <= m; i++){ int u, v; cin >> u >> v; g[u].push_back({v, i}); g[v].push_back({u, i}); } dfs(1); memset(vis, 0, sizeof(vis)); vector<int> cur; for(int &a : path){ if(vis[a]){ while(cur.size()){ cout << cur.back() << ' '; vis[cur.back()] = 0; if(cur.back() == a){ cur.pop_back(); break; } cur.pop_back(); } cout << '\n'; } cur.push_back(a); vis[a] = 1; } } signed main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; // cin >> t; while(t--) solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...