Submission #394387

#TimeUsernameProblemLanguageResultExecution timeMemory
394387Theo830Highway Tolls (IOI18_highway)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll INF = 1e18+7; ll MOD = 998244353; typedef pair<ll,ll> ii; #define iii pair<ll,ii> #define f(i,a,b) for(ll i = a;i < b;i++) #define pb push_back #define vll vector<ll> #define F first #define S second #define all(x) (x).begin(), (x).end() ///I hope I will get uprating and don't make mistakes ///I will never stop programming ///sqrt(-1) Love C++ ///Please don't hack me ///@TheofanisOrfanou Theo830 ///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst) ///Stay Calm ///Look for special cases ///Beware of overflow and array bounds ///Think the problem backwards ///Training #include "highway.h" ll par[90005] = {0}; ll dep[90005] = {0}; vector<vll>adj; void dfs(ll u,ll p){ par[u] = p; for(auto x:adj[u]){ if(x != p){ depth[x] = depth[u] + 1; dfs(x,u); } } } void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) { adj.assign(N+1,vll()); ll m = U.size(); f(i,0,m){ adj[U[i]].pb(V[i]); adj[V[i]].pb(U[i]); } dfs(0,-1); ll s = 0,t; vector<int>w(m); w.assign(m,0); ll ans = ask(w); ll di = ans; ll de = 0; f(i,0,m){ ll x = U[i]; if(par[V[i]] == U[i]){ x = V[i]; } w[x] = 1; if(ask(w) != di){ if(depth[x] > de){ de = depth[x]; t = x; } } w[x] = 0; } answer(s,t); }

Compilation message (stderr)

highway.cpp: In function 'void dfs(ll, ll)':
highway.cpp:33:13: error: 'depth' was not declared in this scope; did you mean 'dep'?
   33 |             depth[x] = depth[u] + 1;
      |             ^~~~~
      |             dep
highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:59:16: error: 'depth' was not declared in this scope; did you mean 'dep'?
   59 |             if(depth[x] > de){
      |                ^~~~~
      |                dep