Submission #559584

#TimeUsernameProblemLanguageResultExecution timeMemory
559584stefantagaSenior Postmen (BOI14_postmen)C++14
38 / 100
597 ms18908 KiB
#include <bits/stdc++.h> using namespace std; struct wow { int x,y; }muchie[500005]; vector <pair <int,int>> v[500005]; int n,m,i,nr[500005],marc[500005],ok1,j,ok[500005]; int main() { ios_base :: sync_with_stdio(false); cin.tie(0); #ifdef HOME ifstream cin("date.in"); ofstream cout("date.out"); #endif // HOME cin>>n>>m; for (i=1;i<=m;i++) { cin>>muchie[i].x>>muchie[i].y; int x = muchie[i].x; int y = muchie[i].y; v[x].push_back({y,i}); v[y].push_back({x,i}); } int q; for (i=1;i<=n;i++) { q=0; nr[++q]=i; while (q) { int acum = nr[q]; marc[acum]=1; ok1=0; for (j=0;j<v[acum].size();j++) { int ind = v[acum][j].second; if (ok[ind]==0) { ok[ind]=1; if (marc[v[acum][j].first]==1) { while (nr[q]!=v[acum][j].first) { marc[nr[q]]=0; cout<<nr[q]<<" "; q--; } cout<<v[acum][j].first<<'\n'; } else { nr[++q]=v[acum][j].first; } ok1=1; break; } } if (ok1==0) { q--; } } } return 0; }

Compilation message (stderr)

postmen.cpp: In function 'int main()':
postmen.cpp:37:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |             for (j=0;j<v[acum].size();j++)
      |                      ~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...