Submission #1119706

#TimeUsernameProblemLanguageResultExecution timeMemory
1119706vjudge1Senior Postmen (BOI14_postmen)C++17
100 / 100
485 ms57048 KiB
#include<bits/stdc++.h> #define ll int using namespace std; const ll N = 5e5 + 5; ll vi[N] , n , m ,k, ok[N]; deque<int> q; vector<pair<int, int>> adj[N]; list <int> duyet(ll u) { list<int> ans; ans.push_back(u); while(!adj[u].empty()) { int v = adj[u].back().first; int id = adj[u].back().second; adj[u].pop_back(); if(vi[id]) continue; vi[id] = 1; u = v; ans.push_back(u); } for (auto it = ++ans.begin(); it != ans.end(); ++it) { auto t = duyet(*it); t.pop_back(); ans.splice(it, t); //for(auto uu : t) ans.push_back(uu); } return ans; } main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> m; for(int i = 1; i <= m ; i ++) { ll x, y; cin >> x >> y; adj[x].push_back({y, i}); adj[y].push_back({x, i}); } list <int> p ; p = duyet(1); stack<int> st; for(auto u : p) { st.push(u); ok[u]++; if(ok[st.top()] > 1) { while(!st.empty()) { ll v = st.top(); if(ok[v] == 1 && v == u) break; ok[v]--; cout << v <<' '; st.pop(); } cout <<'\n'; } } }

Compilation message (stderr)

postmen.cpp:30:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   30 | main()
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...