제출 #227157

#제출 시각아이디문제언어결과실행 시간메모리
227157Bruteforceman어르신 집배원 (BOI14_postmen)C++11
100 / 100
339 ms35320 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 5e5 + 10; struct edge { int l, r; int nxtL, nxtR; } e[maxn]; int idx[maxn]; int del[maxn]; int st[maxn]; int id; void dfs(int x) { while(idx[x] != -1) { int i = idx[x]; int y = e[i].l ^ e[i].r ^ x; idx[x] = (e[i].l == x) ? e[i].nxtL : e[i].nxtR; if(del[i]) continue; del[i] = true; dfs(y); } st[id++] = x; } int main() { int n, m; scanf("%d %d", &n, &m); memset(idx, -1, sizeof idx); for(int i = 0; i < m; i++) { scanf("%d %d", &e[i].l, &e[i].r); e[i].nxtL = idx[e[i].l]; e[i].nxtR = idx[e[i].r]; idx[e[i].l] = idx[e[i].r] = i; } dfs(1); memset(del, false, sizeof del); stack <int> s; for(int i = 0; i < id; i++) { int x = st[i]; s.push(x); if(del[x]) { do { printf("%d ", s.top()); del[s.top()] = false; s.pop(); } while(x != s.top() || !puts("")); } del[x] = true; } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

postmen.cpp: In function 'void dfs(int)':
postmen.cpp:18:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
     if(del[i]) continue; del[i] = true;
     ^~
postmen.cpp:18:26: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
     if(del[i]) continue; del[i] = true;
                          ^~~
postmen.cpp: In function 'int main()':
postmen.cpp:25:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &n, &m);
   ~~~~~^~~~~~~~~~~~~~~~~
postmen.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &e[i].l, &e[i].r);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...