Submission #31530

#TimeUsernameProblemLanguageResultExecution timeMemory
31530KanvieSenior Postmen (BOI14_postmen)C++14
0 / 100
12 ms12032 KiB
#include<bits/stdc++.h> using namespace std; int n,m,x,y,vv,u; map<pair<int,int>,bool>mp; vector<int>v[500001],ans; stack<int>s; int main() { cin>>n>>m; for(int i=1;i<=m;++i) { cin>>x>>y; mp[{x,y}]=true; mp[{y,x}]=true; v[x].push_back(y); v[y].push_back(x); } s.push(1); while(!s.empty()) { u=s.top(); for(int i=0;i<v[u].size();++i) { vv=v[u][i]; if(mp[{vv,u}]==true) { mp[{vv,u}]=false; mp[{u,vv}]=false; break; } if(i==v[u].size()-1)vv=-1; } if(vv!=-1)s.push(vv); else {s.pop();ans.push_back(u);} } for(int i=0;i<ans.size()-3;++i)cout<<ans[i]<<' ';cout<<ans[ans.size()-3]; }

Compilation message (stderr)

postmen.cpp: In function 'int main()':
postmen.cpp:22:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i=0;i<v[u].size();++i)
                     ~^~~~~~~~~~~~
postmen.cpp:31:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(i==v[u].size()-1)vv=-1;
                ~^~~~~~~~~~~~~~~
postmen.cpp:36:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<ans.size()-3;++i)cout<<ans[i]<<' ';cout<<ans[ans.size()-3];
                 ~^~~~~~~~~~~~~
postmen.cpp:36:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
     for(int i=0;i<ans.size()-3;++i)cout<<ans[i]<<' ';cout<<ans[ans.size()-3];
     ^~~
postmen.cpp:36:54: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
     for(int i=0;i<ans.size()-3;++i)cout<<ans[i]<<' ';cout<<ans[ans.size()-3];
                                                      ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...