Submission #26872

#TimeUsernameProblemLanguageResultExecution timeMemory
26872top34051어르신 집배원 (BOI14_postmen)C++14
38 / 100
1094 ms23416 KiB
#include<bits/stdc++.h> using namespace std; #define maxn 500005 int n,m; int out[maxn]; bool vis[maxn]; vector<pair<int,int> > from[maxn]; stack<pair<int,int> > st; void dfs(int x,int last) { int i,y; if(out[x]) { while(!st.empty()) { y = st.top().first; printf("%d ",y); out[y]--; st.pop(); if(y==x) break; } printf("\n"); } for(i=0;i<from[x].size();i++) { if(!vis[from[x][i].second]) { out[x]++; st.push({x,from[x][i].first}); vis[from[x][i].second] = 1; dfs(from[x][i].first,x); } } } main() { int i,x,y; scanf("%d%d",&n,&m); for(i=1;i<=m;i++) { scanf("%d%d",&x,&y); from[x].push_back({y,i}); from[y].push_back({x,i}); } dfs(1,0); }

Compilation message (stderr)

postmen.cpp: In function 'void dfs(int, int)':
postmen.cpp:21:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(i=0;i<from[x].size();i++) {
             ~^~~~~~~~~~~~~~~
postmen.cpp: At global scope:
postmen.cpp:30:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
postmen.cpp: In function 'int main()':
postmen.cpp:32: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:34: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...