Submission #466797

#TimeUsernameProblemLanguageResultExecution timeMemory
466797M4mouSenior Postmen (BOI14_postmen)C++17
0 / 100
4 ms3020 KiB
#include <bits/stdc++.h> using namespace std; bool v[500005],queued[500005]; int next0[500005]; vector<vector<pair<int,int>>> graph; int dfs(int x, int p){ if(queued[x]){ cout << x << " "; return x; } queued[x] = 1; // cout << x << endl; for(;next0[x]<graph[x].size();next0[x]++){ auto edge = graph[x][next0[x]]; if(v[edge.second] || p == x)continue; v[edge.second] = 1; int y = dfs(edge.first,x); queued[x] = 0; if(x != y){ cout << x << " "; return y; } cout << '\n'; } return -1; } int main(){ memset(v , 0, sizeof v); memset(next0,0,sizeof next0); int n,m; cin >> n >> m; graph.resize(n+1); while(m--){ int x , y; cin >> x >> y; graph[x].push_back({y,m}); graph[y].push_back({x,m}); } for(int i = 1;i<=n;i++)dfs(i,-1); }

Compilation message (stderr)

postmen.cpp: In function 'int dfs(int, int)':
postmen.cpp:14:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for(;next0[x]<graph[x].size();next0[x]++){
      |          ~~~~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...