# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
356252 | parsabahrami | Senior Postmen (BOI14_postmen) | C++17 | 869 ms | 93716 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.
// Call my Name and Save me from The Dark
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,fma")
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
#define SZ(x) (int) x.size()
#define F first
#define S second
const int N = 5e5 + 10;
int M[N], ptr[N], from[N], to[N], n, m; vector<int> adj[N]; set<pii> tr;
void tour(int v) {
while (ptr[v] < SZ(adj[v])) {
int id = adj[v][ptr[v]++]; int u = from[id] ^ v ^ to[id];
if (!M[id]) M[id] = 1, tour(u);
}
tr.insert({SZ(tr) + 1, v});
}
int main() {
scanf("%d%d", &n, &m);
for (int i = 1; i <= m; i++) {
scanf("%d%d", &from[i], &to[i]);
adj[from[i]].push_back(i);
adj[to[i]].push_back(i);
}
for (int i = 1; i <= n; i++) assert(!(SZ(adj[i]) & 1));
tour(1);
memset(M, 0, sizeof M);
for (auto it = tr.begin(); it != tr.end(); it = tr.upper_bound(*it)) {
if (M[it->S]) {
for (auto it2 = tr.lower_bound({M[it->S], it->S}); it2 != it;) {
M[it2->S] = 0;
printf("%d ", it2->S);
it2 = tr.erase(it2);
}
printf("\n");
M[it->S] = it->F;
} else M[it->S] = it->F;
}
return 0;
}
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... |