Submission #394392

#TimeUsernameProblemLanguageResultExecution timeMemory
394392Theo830Highway 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 depth[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,t; vector<int>w(m); w.assign(m,0); ll di = ask(w) / A; ll l = 0,r = n-1; while(l <= r){ ll mid = (l+r)/2; w.assign(m,0); f(i,l,mid){ w[l] = 1; } ll g = ask(w); if(g == di * B){ r = mid - 1; } else if(g == di * A){ l = mid + 1; } else{ ll a = (g - di * B) / (A - B); ll b = di - a; s = mid - a; t = mid + b - 1; break; } } answer(s,t); }

Compilation message (stderr)

highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:50:18: error: 'n' was not declared in this scope
   50 |     ll l = 0,r = n-1;
      |                  ^