# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
49491 | minkank | Senior Postmen (BOI14_postmen) | C++14 | 534 ms | 55624 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>
using namespace std;
typedef pair<int, int> ii;
const int N = 5e5 + 5;
int n, m, st[N], p, ptr[N];
bool check[N], sax[N];
vector<int> s[N];
vector<ii> edge;
void dfs(int u) {
while(ptr[u] >= 0) {
int id = s[u][ptr[u]]; ptr[u]--;
if(sax[id]) continue;
sax[id] = true;
int v; if(edge[id].first == u) v = edge[id].second; else v = edge[id].first;
dfs(v);
}
if(check[u]) {
while(st[p] != u) printf("%d ", st[p]), check[st[p]] = false, p--; p--;
printf("%d\n", u);
}
check[u] = 1; ++p; st[p] = u;
}
void get(int &x) {
x = 0;
char c = getchar();
while(c > '9' || c < '0') c = getchar();
while(c >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - '0', c = getchar();
}
int main() {
get(n); get(m);
for(int i = 1; i <= m; ++i) {
int u, v;
get(u); get(v);
s[u].push_back(edge.size()); s[v].push_back(edge.size());
edge.push_back(ii(u, v));
}
for(int i = 1; i <= n; ++i) ptr[i] = s[i].size() - 1;
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... |