# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
240462 | karma | Senior Postmen (BOI14_postmen) | C++14 | 549 ms | 65376 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 <bits/stdc++.h>
#define pb emplace_back
#define ll long long
#define fi first
#define se second
#define mp make_pair
//#define int int64_t
using namespace std;
const int N = int(5e5) + 7;
typedef pair<int, int> pii;
struct TEdge {
int u, v;
bool del;
} e[N];
int n, m, vis[N];
vector<int> st, ss, adj[N];
void euler(int u) {
int i;
while(adj[u].size()) {
if(e[adj[u].back()].del) {
adj[u].pop_back();
continue;
}
i = adj[u].back();
adj[u].pop_back();
e[i].del = 1;
euler(e[i].u ^ e[i].v ^ u);
}
st.pb(u);
}
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
#define Task "test"
if(fopen(Task".inp", "r")) {
freopen(Task".inp", "r", stdin);
freopen(Task".out", "w", stdout);
}
cin >> n >> m;
for(int i = 1; i <= m; ++i) {
cin >> e[i].u >> e[i].v;
adj[e[i].u].pb(i);
adj[e[i].v].pb(i);
}
euler(1);
for(int x: st) {
if(vis[x]) {
while(ss.size()) {
vis[n = ss.back()] = 0;
cout << n << ' ';
ss.pop_back();
if(n == x) break;
}
cout << '\n';
}
vis[x] = 1;
ss.pb(x);
}
}
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... |