Submission #1260733

#TimeUsernameProblemLanguageResultExecution timeMemory
1260733chikien2009Senior Postmen (BOI14_postmen)C++20
100 / 100
190 ms73244 KiB
#include <bits/stdc++.h> using namespace std; void setup() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int n, m, a, b; bool check[500000], mark[500000]; vector<pair<int, int>> g[500000]; vector<int> v; inline void DFS(int node) { if (check[node]) { while (!v.empty() && check[node]) { cout << v.back() + 1 << " "; check[v.back()] = false; v.pop_back(); } cout << "\n"; } while (!g[node].empty()) { a = g[node].back().first; b = g[node].back().second; g[node].pop_back(); if (!mark[b]) { mark[b] = check[node] = true; v.push_back(node); DFS(a); } } } int main() { setup(); cin >> n >> m; for (int i = 0; i < m; ++i) { cin >> a >> b; g[a - 1].push_back({b - 1, i}); g[b - 1].push_back({a - 1, i}); } DFS(0); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...