Submission #733344

#TimeUsernameProblemLanguageResultExecution timeMemory
733344TrunktySenior Postmen (BOI14_postmen)C++14
55 / 100
660 ms223468 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define int ll int n,m; vector<int> roads[500005]; int poi[500005]; unordered_map<int,bool> mp[500005]; bool vis[500005]; vector<int> curr; vector<vector<int>> ans; void euler(int x){ if(vis[x]){ curr = {x}; return; } vis[x] = true; while(roads[x].size()!=poi[x]){ int p = roads[x][poi[x]]; poi[x]++; if(mp[x][p]){ continue; } mp[p][x] = true; euler(p); if(curr.size()>0 and curr[0]!=x){ curr.push_back(x); vis[x] = false; return; } else if(curr[0]==x){ ans.push_back(curr); curr.clear(); } } } signed main(){ ios::sync_with_stdio(false); cin.tie(NULL); cin >> n >> m; for(int i=1;i<=m;i++){ int a,b; cin >> a >> b; roads[a].push_back(b); roads[b].push_back(a); } for(int i=1;i<=n;i++){ if(roads[i].size()>0){ euler(i); } } for(vector<int> i:ans){ for(int j:i){ cout << j << " "; } cout << "\n"; } return 0; }

Compilation message (stderr)

postmen.cpp: In function 'void euler(ll)':
postmen.cpp:20:26: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   20 |     while(roads[x].size()!=poi[x]){
      |           ~~~~~~~~~~~~~~~^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...