Submission #227313

#TimeUsernameProblemLanguageResultExecution timeMemory
227313BruteforcemanSenior Postmen (BOI14_postmen)C++11
55 / 100
517 ms74236 KiB
#include <bits/stdc++.h> using namespace std; #define prev dfsdf forward_list <int> g[500010]; int l[500010], r[500010]; bool del[500010]; int tour[1000010]; bool occ[500010]; int cur; void dfs(int x) { while (!g[x].empty()){ int i = g[x].front(); g[x].pop_front(); if(del[i]) continue; del[i] = true; int y = l[i] ^ r[i] ^ x; dfs(y); } if(occ[x] == false) { occ[x] = true; tour[++cur] = x; } else { while(tour[cur] != x) { int y = tour[cur--]; occ[y] = false; printf("%d ", y); } printf("%d\n", x); } } int main (int argc, char const* argv[]) { int n, m; scanf("%d %d", &n, &m); for(int i = 0; i < m; i++) { int p, q; scanf("%d %d", &p, &q); l[i] = p; r[i] = q; g[p].push_front(i); g[q].push_front(i); } dfs(1); return 0; }

Compilation message (stderr)

postmen.cpp: In function 'int main(int, const char**)':
postmen.cpp:35: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:38:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &p, &q);
   ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...