# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
31482 | minkank | Senior Postmen (BOI14_postmen) | C++14 | 935 ms | 115260 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <set>
#include <stack>
using namespace std;
const int N = 5e5 + 5;
int n, m, cnt[N];
set<int> s[N];
stack<int> st;
void dfs(int u) {
while(s[u].size()) {
int v = *s[u].begin();
s[u].erase(v); s[v].erase(u);
dfs(v);
}
if(cnt[u]) {
cout << u << ' ';
while(st.top() != u) cout << st.top() << ' ', cnt[st.top()]--, st.pop(); cnt[st.top()]--; st.pop();
cout << endl;
}
cnt[u]++; st.push(u);
}
int main() {
cin >> n >> m;
for(int i = 1; i <= m; ++i) {
int u, v;
cin >> u >> v;
s[u].insert(v); s[v].insert(u);
}
dfs(1);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |