# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
98425 | Kastanda | Senior Postmen (BOI14_postmen) | C++11 | 400 ms | 19532 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;
const int N = 500005;
int n, m, ets, cyc, to[N + N], M[N], S[N];
int head[N], nxt[N + N];
int ts, st[N];
int v, u;
inline void DFS()
{
ts = 0;
st[++ ts] = v;
while (ts)
{
v = st[ts]; S[v] = 1;
for (; ~head[v]; )
{
u = to[head[v]];
if (M[head[v] >> 1])
{
head[v] = nxt[head[v]];
continue;
}
M[head[v] >> 1] = 1;
head[v] = nxt[head[v]];
if (S[u])
{
while (st[ts] != u)
{
printf("%d ", st[ts]);
S[st[ts]] = 0; ts --;
}
printf("%d\n", u);
ts ++;
break;
}
st[++ ts] = u;
ts ++;
break;
}
ts --;
}
}
inline void Add(int vv, int uu)
{
to[ets] = uu;
nxt[ets] = head[vv];
head[vv] = ets; ets ++;
}
int main()
{
scanf("%d%d", &n, &m);
memset(head, -1, sizeof(head));
for (int i = 1; i <= m; i++)
{
int vv, uu;
scanf("%d%d", &vv, &uu);
Add(vv, uu); Add(uu, vv);
}
for (int i = 1; i <= n; i++)
v = i, DFS();
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... |