Submission #6159

#TimeUsernameProblemLanguageResultExecution timeMemory
6159aintaSenior Postmen (BOI14_postmen)C++98
100 / 100
395 ms21368 KiB
#pragma warning(disable:4996) #include<stdio.h> #include<algorithm> int nxt[1000010], ed[1000010], num[500010]; int n, m, used[1000010], v[500010]; int st[500010]; void Do(int start){ int top = 0, x, y; st[++top] = start; v[start] = true; while (1){ while (top){ while (used[num[st[top]]])num[st[top]] = nxt[num[st[top]]]; if (!num[st[top]]){ v[st[top]] = false; top--; } else break; } if (!top)break; x = st[top]; y = ed[num[x]]; used[num[x]] = used[num[x] ^ 1] = true; num[x] = nxt[num[st[top]]]; if (v[y]){ while (1){ printf("%d ", st[top]); if (st[top] == y)break; v[st[top]] = false; top--; } printf("\n"); continue; } else{ st[++top] = y; v[y] = true; } } v[start] = false; } int main() { int i, a, b, cnt = 1; scanf("%d%d", &n, &m); for (i = 0; i < m; i++){ scanf("%d%d", &a, &b); ed[++cnt] = b; nxt[cnt] = num[a]; num[a] = cnt; ed[++cnt] = a; nxt[cnt] = num[b]; num[b] = cnt; } for (i = 1; i <= n; i++){ Do(i); } return 0; }

Compilation message (stderr)

postmen.cpp:1:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
 #pragma warning(disable:4996)
 
postmen.cpp: In function 'int main()':
postmen.cpp:45:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~
postmen.cpp:47:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &a, &b);
   ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...