Submission #826385

#TimeUsernameProblemLanguageResultExecution timeMemory
826385alvingogoThousands Islands (IOI22_islands)C++17
Compilation error
0 ms0 KiB
#include "islands.h" #include <bits/stdc++.h> #include <variant> #define fs first #define sc second using namespace std; vector<vector<pair<int,int> > > e; vector<int> ans; int dfs(int r,int f){ dep[r]=dep[f]+1; fa[r]=f; for(auto h:e[r]){ if(dep[h.fs]==-1){ if(dfs(h.fs,r)){ return 1; } } else if(dep[h.fs]>=0){ vector<int> bz; for(int i=0;i!=h.fs;){ for(auto w:e[i]){ if(dep[w.fs]==dep[i]+1){ bz.push_back(w.sc); i=w.fs; break; } } } vector<int> cz,dz; for(int i=h.fs;i!=r;){ for(auto w:e[i]){ if(dep[w.fs]==dep[i]+1){ cz.push_back(w.sc); dz.push_back(w.sc+1); i=w.fs; break; } } } ans.insert(ans.end(),bz.begin(),bz.end()); ans.insert(ans.end(),cz.begin(),cz.end()); ans.insert(ans.end(),dz.begin(),dz.end()); reverse(bz.begin(),bz.end()); reverse(cz.begin(),cz.end()); reverse(dz.begin(),dz.end()); ans.insert(ans.end(),cz.begin(),cz.end()); ans.insert(ans.end(),dz.begin(),dz.end()); ans.insert(ans.end(),bz.begin(),bz.end()); return 1; } } dep[h.fs]=-2; return 0; } variant<bool, vector<int>> find_journey( int n, int m, vector<int> u, vector<int> v) { e.resize(n); ss.resize(m); fa.resize(n); sf.resize(n); dep.resize(n,-1); for(int i=0;i<m;i+=2){ e[u[i]].push_back({v[i],i}); } ava.resize(n,vector<int>(n)); if(!dfs(0,0)){ return false; } return ans; }

Compilation message (stderr)

islands.cpp: In function 'int dfs(int, int)':
islands.cpp:11:5: error: 'dep' was not declared in this scope
   11 |     dep[r]=dep[f]+1;
      |     ^~~
islands.cpp:12:5: error: 'fa' was not declared in this scope; did you mean 'f'?
   12 |     fa[r]=f;
      |     ^~
      |     f
islands.cpp:53:9: error: 'h' was not declared in this scope
   53 |     dep[h.fs]=-2;
      |         ^
islands.cpp: In function 'std::variant<bool, std::vector<int, std::allocator<int> > > find_journey(int, int, std::vector<int>, std::vector<int>)':
islands.cpp:59:5: error: 'ss' was not declared in this scope; did you mean 'sc'?
   59 |     ss.resize(m);
      |     ^~
      |     sc
islands.cpp:60:5: error: 'fa' was not declared in this scope; did you mean 'fma'?
   60 |     fa.resize(n);
      |     ^~
      |     fma
islands.cpp:61:5: error: 'sf' was not declared in this scope; did you mean 'sc'?
   61 |     sf.resize(n);
      |     ^~
      |     sc
islands.cpp:62:5: error: 'dep' was not declared in this scope
   62 |     dep.resize(n,-1);
      |     ^~~
islands.cpp:66:5: error: 'ava' was not declared in this scope
   66 |     ava.resize(n,vector<int>(n));
      |     ^~~