Submission #399721

#TimeUsernameProblemLanguageResultExecution timeMemory
399721A_DFun Tour (APIO20_fun)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int N=5011; set<int> g[N]; int n,uu; int d; void dfs(int u,int p,int dep) { if(dep>d){ d=dep; uu=u; } for(auto x:g[u]){ if(x==p)continue; dfs(x,u,dep+1); } } std::vector<int> createFunTour(int N, int Q) { //int H = hoursRequired(0, N - 1); //int A = attractionsBehind(0, N - 1); return std::vector<int>(N); n=N; for(int i=0;i<n;i++){ for(int j=i+1;j<n;j++){ int h=hoursRequired(i, j); if(h==1){ g[i].insert(j); g[j].insert(i); } } } vector<int> ret; d=0; dfs(uu,uu,0); while(g[u].empty()==0){ d=0; int v=uu; ret.push_back(v); dfs(uu,uu,0); int x=*g[v].begin(); g[v].erase(x); g[x].erase(v); } return ret; }

Compilation message (stderr)

fun.cpp: In function 'std::vector<int> createFunTour(int, int)':
fun.cpp:25:19: error: 'hoursRequired' was not declared in this scope
   25 |             int h=hoursRequired(i, j);
      |                   ^~~~~~~~~~~~~
fun.cpp:35:13: error: 'u' was not declared in this scope
   35 |     while(g[u].empty()==0){
      |             ^