Submission #31536

#TimeUsernameProblemLanguageResultExecution timeMemory
31536minkankSenior Postmen (BOI14_postmen)C++14
55 / 100
560 ms61416 KiB
#include <iostream> #include <set> #include <stack> #include <vector> using namespace std; typedef pair<int, int> ii; const int N = 5e5 + 5; int n, m, st[N], p; bool check[N], sax[N]; vector<int> s[N]; vector<ii> edge; void dfs(int u) { while(s[u].size()) { int id = s[u].back(); s[u].pop_back(); if(sax[id]) continue; sax[id] = true; int v; if(edge[id].first == u) v = edge[id].second; else v = edge[id].first; dfs(v); } if(check[u]) { while(st[p] != u) cout << st[p] << ' ', check[st[p]] = false, p--; p--; cout << u << '\n'; } check[u] = 1; ++p; st[p] = u; } void get(int &x) { x = 0; char c = getchar(); while(c > '9' || c < '0') c = getchar(); while(c >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - '0', c = getchar(); } int main() { get(n); get(m); for(int i = 1; i <= m; ++i) { int u, v; get(u); get(v); s[u].push_back(edge.size()); s[v].push_back(edge.size()); edge.push_back(ii(u, v)); } dfs(1); }

Compilation message (stderr)

postmen.cpp: In function 'void dfs(int)':
postmen.cpp:24:3: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
   while(st[p] != u) cout << st[p] << ' ', check[st[p]] = false, p--; p--;
   ^~~~~
postmen.cpp:24:70: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
   while(st[p] != u) cout << st[p] << ' ', check[st[p]] = false, p--; p--;
                                                                      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...