제출 #31534

#제출 시각아이디문제언어결과실행 시간메모리
31534ngkan146어르신 집배원 (BOI14_postmen)C++98
0 / 100
24 ms23876 KiB
#include <bits/stdc++.h> using namespace std; struct edge{ int v=0, id=0; edge(int v=0,int id=0):id(id),v(v){} }; int ctrl[1000005]; vector <edge> G[1000005]; bool visited[1000005]; int n,m; int euler[1000005], eulersize; int q[1000005], qsize; void dfs(){ q[qsize++] = 1; while(qsize){ int u = q[qsize-1]; bool mjk = 0; for(;ctrl[u]<G[u].size();++ctrl[u]){ int v = G[u][ctrl[u]].v; int id = G[u][ctrl[u]].id; if (visited[id]) continue; mjk = 1; visited[id] = 1; q[qsize]++; break; } if(mjk) continue; euler[eulersize++] = u; --qsize; } } int st[1000005], stsize; bool used[1000005]; int main(){ scanf("%d %d",&n,&m); for(int i=1;i<=m;++i){ int x,y; scanf("%d %d",&x,&y); G[x].push_back(edge(y,i)); G[y].push_back(edge(x,i)); } dfs(); for(int i=0;i<eulersize;++i){ if (used[euler[i]]){ while(st[stsize-1] != euler[i]){ printf("%d ",st[stsize-1]); used[st[stsize-1]] = 0; --stsize; }; printf("%d\n",euler[i]); } else{ st[stsize++] = euler[i]; used[euler[i]] = 1; } } }

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

postmen.cpp: In constructor 'edge::edge(int, int)':
postmen.cpp:4:17: warning: 'edge::id' will be initialized after [-Wreorder]
     int v=0, id=0;
                 ^
postmen.cpp:4:11: warning:   'int edge::v' [-Wreorder]
     int v=0, id=0;
           ^
postmen.cpp:5:5: warning:   when initialized here [-Wreorder]
     edge(int v=0,int id=0):id(id),v(v){}
     ^~~~
postmen.cpp: In function 'void dfs()':
postmen.cpp:19:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(;ctrl[u]<G[u].size();++ctrl[u]){
              ~~~~~~~^~~~~~~~~~~~
postmen.cpp:20:17: warning: unused variable 'v' [-Wunused-variable]
             int v = G[u][ctrl[u]].v;
                 ^
postmen.cpp: In function 'int main()':
postmen.cpp:38: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:41:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d",&x,&y);
         ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...