제출 #11591

#제출 시각아이디문제언어결과실행 시간메모리
11591gs14004어르신 집배원 (BOI14_postmen)C++98
100 / 100
427 ms25500 KiB
#include <cstdio> #include <vector> #include <stack> #include <cstring> using namespace std; int n,m; int st[1000005], back[1000005], link[1000005], v[500005], nex[1000005], sz; vector<int> cyc, temp; void add_edge(int s, int e){ sz++; link[sz] = e; back[sz] = st[s]; st[s] = sz; nex[back[sz]] = sz; sz++; link[sz] = s; back[sz] = st[e]; st[e] = sz; nex[back[sz]] = sz; } void f(int x){ stack<int> s; s.push(1); while (!s.empty()) { int x = s.top(); int p = st[x]; int pushed = 0; while (p) { int pos = link[p]; int q = (p+1)/2; int r = p; if(p&1) r++; else r--; st[x] = p = back[p]; if(r == st[pos]){ st[pos] = back[r]; } else{ int s = nex[r]; back[s] = back[r]; nex[back[r]] = s; } if(!v[q]){ v[q]=1; s.push(pos); pushed++; break; } } if(!pushed) s.pop(); if(!pushed) cyc.push_back(x); } } int vis[500005]; int main(){ scanf("%d %d",&n,&m); for (int i=0; i<m; i++) { int s,e; scanf("%d %d",&s,&e); add_edge(s,e); } f(1); for (int i=0; i<cyc.size(); i++) { temp.push_back(cyc[i]); if(vis[cyc[i]]){ printf("%d",temp.back()); temp.pop_back(); while(temp.back() != cyc[i]){ printf(" %d",temp.back()); vis[temp.back()] = 0; temp.pop_back(); if(temp.back() == cyc[i]) printf("\n"); } } else vis[cyc[i]] = 1; } }

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

postmen.cpp: In function 'int main()':
postmen.cpp:62:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0; i<cyc.size(); i++) {
                   ~^~~~~~~~~~~
postmen.cpp:55:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d",&n,&m);
     ~~~~~^~~~~~~~~~~~~~~
postmen.cpp:58:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d",&s,&e);
         ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...