Submission #492148

#TimeUsernameProblemLanguageResultExecution timeMemory
492148tht2005Senior Postmen (BOI14_postmen)C++14
100 / 100
275 ms65060 KiB
#include <cstdio> #include <cstdlib> #include <cstring> #define N 500050 struct edge_t { int v, f; edge_t *nxt, *rev; } e[N * 2], *adj[N], *ptr = e; int vst[N], prv[N]; void addedge(int i, int j) { edge_t* p = ptr++, *q = ptr++; p->v = j, p->f = 0, p->nxt = adj[i], p->rev = q, adj[i] = p; q->v = i, q->f = 0, q->nxt = adj[j], q->rev = p, adj[j] = q; } void dfs(int i) { if(vst[i]) { while(vst[i]) { vst[i] = 0; printf("%d ", i); i = prv[i]; } putchar('\n'); } while(adj[i]) { edge_t* p = adj[i]; adj[i] = adj[i]->nxt; if(p->f) continue; p->f = p->rev->f = 1; vst[i] = 1; prv[i] = p->v; dfs(p->v); } } int main() { int n, m; scanf("%d %d", &n, &m); while(m--) { int i, j; scanf("%d %d", &i, &j); addedge(i, j); } dfs(1); return 0; }

Compilation message (stderr)

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