Submission #984065

#TimeUsernameProblemLanguageResultExecution timeMemory
984065rumbinSenior Postmen (BOI14_postmen)C++17
0 / 100
1 ms440 KiB
#include <bits/stdc++.h> using namespace std; vector<set<int>> E; vector<vector<int>> A; vector<int> V,P,S; int t = 1,sum=0; void dfs(int u, int p, int s) { int cur = u; while(!E[cur].empty()) { auto i = E[cur].begin(); P.push_back(cur); int v= *i; E[v].erase(E[v].find(cur)); E[cur].erase(i++); cur = v; } P.push_back(u); } void trace(int i) { int k = A.size(); A.push_back({}); for(int j=i;j<S[i]; j++) { V[j] = 1; if(S[j] != -1 && S[j] < S[i]) { trace(j); j = S[j]-1; } else { A[k].push_back(P[j]); sum++; } } } int main() { int N,M; cin>>N>>M; E.assign(N+1,{}); V.assign(N+1,false); for(int i=0; i<M; i++) { int u,v; cin>>u>>v; E[u].insert(v); E[v].insert(u); } dfs(1,0,1); S.assign(P.size(),-1); V.assign(N+1, -1); for(int i=0; i<P.size(); i++) { if(V[P[i]] != -1) S[V[P[i]]] = i; V[P[i]] = i; } V.assign(P.size(), 0); for(int i=0; i<P.size(); i++) if(!V[i]&&S[i] != -1) trace(i); for(int i=0; i<A.size(); i++) { for(int j=0; j<A[i].size(); j++) cout<<A[i][j]<<' '; cout<<endl; } }

Compilation message (stderr)

postmen.cpp: In function 'int main()':
postmen.cpp:62:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |  for(int i=0; i<P.size(); i++)
      |               ~^~~~~~~~~
postmen.cpp:69:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |  for(int i=0; i<P.size(); i++)
      |               ~^~~~~~~~~
postmen.cpp:72:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |  for(int i=0; i<A.size(); i++)
      |               ~^~~~~~~~~
postmen.cpp:74:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   74 |   for(int j=0; j<A[i].size(); j++)
      |                ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...