Submission #1101695

#TimeUsernameProblemLanguageResultExecution timeMemory
1101695PagodePaivaSenior Postmen (BOI14_postmen)C++17
55 / 100
1070 ms133792 KiB
#include<bits/stdc++.h> using namespace std; const int N = 500010; vector <pair <int, int>> g[N]; int mark[N]; map <pair <int,int>, int> arestas; vector <int> path; void dfs(int v){ while(!g[v].empty()){ auto [x, idx] = g[v].back(); g[v].pop_back(); if(mark[idx]) continue; mark[idx] = 1; dfs(x); } path.push_back(v); } int main(){ int n,m; cin >> n >> m; for(int i = 0;i <m;i++){ int a, b; cin >> a >> b; g[a].push_back({b, i}); g[b].push_back({a, i}); arestas[{a, b}] = i; arestas[{b, a}] = i; } dfs(1); memset(mark, 0, sizeof mark); vector <vector <int>> v; stack <int> at; for(int i = 0;i < path.size();i++){ if(mark[path[i]] == 0) { mark[path[i]] = 1; at.push(path[i]); } else{ vector <int> aux; aux.push_back(path[i]); while(!at.empty()){ if(at.top() == path[i]) break; aux.push_back(at.top()); mark[at.top()] = 0; at.pop(); } aux.push_back(path[i]); v.push_back(aux); } } for(auto vv : v){ for(int i = 0;i < vv.size()-1;i++){ cout << vv[i] << ' '; } cout << '\n'; } }

Compilation message (stderr)

postmen.cpp: In function 'int main()':
postmen.cpp:37:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for(int i = 0;i < path.size();i++){
      |                   ~~^~~~~~~~~~~~~
postmen.cpp:56:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |        for(int i = 0;i < vv.size()-1;i++){
      |                      ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...