Submission #1239816

#TimeUsernameProblemLanguageResultExecution timeMemory
1239816MarwenElarbiThousands Islands (IOI22_islands)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "islands.h" using namespace std; #define fi first #define se second #define pb push_back mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); vector<int> adj[1005]; bool vis[1005]; bool test=false; vector<int> ans; bool dfs(int x,int p){ vis[x]=true; ans.push_back(x); if(adj[x].size()==3){ int a=-1,b=-1; for(auto u : adj[x]){ if(u==p) continue; if(a==-1) a=u; else b=u; } ans.push_back(a); ans.push_back(x); ans.push_back(b); ans.push_back(x); ans.push_back(a); ans.push_back(x); ans.push_back(b); ans.push_back(x); return true; } bool test=false; for(auto u:adj[x]){ if(vis[u]) continue; if(dfs(u,x)){ test=true; break; } } if(!test) ans.pop_back(); else ans.push_back(x); return test; } std::variant<bool, std::vector<int>> find_journey( int N, int M, std::vector<int> U, std::vector<int> V) { for (int i = 0; i < M; ++i) { adj[U[i]].push_back(V[i]); } if(adj[0].size()==2){ return vector<int>({0,adj[0][0],0,adj[0][1],0,adj[0][0],0,adj[0][1],0}); } if(dfs(0)) return ans; return false; }

Compilation message (stderr)

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:53:11: error: too few arguments to function 'bool dfs(int, int)'
   53 |     if(dfs(0)) return ans;
      |        ~~~^~~
islands.cpp:12:6: note: declared here
   12 | bool dfs(int x,int p){
      |      ^~~