Submission #49491

#TimeUsernameProblemLanguageResultExecution timeMemory
49491minkankSenior Postmen (BOI14_postmen)C++14
55 / 100
534 ms55624 KiB
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> ii; const int N = 5e5 + 5; int n, m, st[N], p, ptr[N]; bool check[N], sax[N]; vector<int> s[N]; vector<ii> edge; void dfs(int u) { while(ptr[u] >= 0) { int id = s[u][ptr[u]]; ptr[u]--; 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) printf("%d ", st[p]), check[st[p]] = false, p--; p--; printf("%d\n", u); } 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)); } for(int i = 1; i <= n; ++i) ptr[i] = s[i].size() - 1; dfs(1); }

Compilation message (stderr)

postmen.cpp: In function 'void dfs(int)':
postmen.cpp:21:3: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
   while(st[p] != u) printf("%d ", st[p]), check[st[p]] = false, p--; p--;
   ^~~~~
postmen.cpp:21:70: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
   while(st[p] != u) printf("%d ", 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...