제출 #31518

#제출 시각아이디문제언어결과실행 시간메모리
31518ngkan146어르신 집배원 (BOI14_postmen)C++11
55 / 100
563 ms53724 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[500005]; vector <edge> G[500005]; bool visited[500005]; int n,m; vector <int> euler; void dfs(int u){ 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; visited[id] = 1; dfs(v); } euler.push_back(u); } stack <int> st; bool used[500005]; 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(1); for(int i=0;i<euler.size();i++){ if (used[euler[i]]){ while(st.top() != euler[i]){ used[st.top()] = 0; printf("%d ",st.top()); st.pop(); }; printf("%d\n",euler[i]); } else{ st.push(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(int)':
postmen.cpp:13:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(;ctrl[u]<G[u].size();ctrl[u]++){
          ~~~~~~~^~~~~~~~~~~~
postmen.cpp: In function 'int main()':
postmen.cpp:35:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<euler.size();i++){
                 ~^~~~~~~~~~~~~
postmen.cpp:25: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:28: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...