Submission #31510

#TimeUsernameProblemLanguageResultExecution timeMemory
31510cheater2kSenior Postmen (BOI14_postmen)C++14
55 / 100
566 ms44024 KiB
#include <bits/stdc++.h> using namespace std; const int N = 500010; int n, m; vector < pair<int,int> > G[N]; vector <int> E; bool del[N]; int pos[N]; inline void dfs(int u) { while(!G[u].empty()) { int id = G[u].back().first, v = G[u].back().second; if (del[id]) { G[u].pop_back(); continue; } else del[id] = 1, dfs(v); } E.push_back(u); } int main() { //freopen("out.txt", "w", stdout); ios_base::sync_with_stdio(false); cin.tie(0); scanf("%d%d", &n, &m); for (int i = 1; i <= m; ++i) { int u, v; scanf("%d%d", &u, &v); G[u].push_back(make_pair(i,v)); G[v].push_back(make_pair(i,u)); } dfs(1); //for (int u: E) cerr << u << ' '; cerr << endl; stack <int> s; for (int i = 0; i < (int)E.size(); ++i) { int u = E[i]; if (!pos[u]) { pos[u] = 1; s.push(u); } else { while(s.top() != u) { printf("%d ", s.top()); pos[s.top()] = 0; s.pop(); } printf("%d\n", u); } } }

Compilation message (stderr)

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