Submission #98425

#TimeUsernameProblemLanguageResultExecution timeMemory
98425KastandaSenior Postmen (BOI14_postmen)C++11
100 / 100
400 ms19532 KiB
#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)

postmen.cpp: In function 'int main()':
postmen.cpp:51:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~
postmen.cpp:56:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &vv, &uu);
         ~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...