Submission #1111945

# Submission time Handle Problem Language Result Execution time Memory
1111945 2024-11-13T12:29:25 Z epicci23 Highway Tolls (IOI18_highway) C++17
Compilation error
0 ms 0 KB
#include "bits/stdc++.h"
#include "highway.h"
#define ll long long
#define all(v) v.begin() , v.end()
#define sz(a) (ll)a.size()
using namespace std;

const ll N = 2e5 + 5;

vector<ll> v[N],Xor,depth[N],Res;
ll n,m,A,B,Dist,vis[N],par[N],sub[N];

inline ll oth(ll c,ll u) {return Xor[c] ^ u;}

void upd(ll c,ll d){
  sub[c]=1;
  depth[d].push_back(c);
  for(ll ind:v[c]){
    ll x = oth(ind,c);
  	if(ind==par[c] || vis[x]) continue;
  	par[x]=ind;
    upd(x,d+1);
    sub[c]+=sub[x];
  }
}

ll we_know_root(ll rt){
  for(ll i=0;i<N;i++) depth[i].clear();
  par[rt]=-1;
  upd(rt,0);
  ll l = 0 , r = sz(depth[Dist]) - 1;
  
  while(l<r){
  	ll mid = (l+r)/2;
    Res.assign(m,0);
    for(ll i=0;i<=mid;i++){
      ll cur = depth[Dist][i];
      while(cur != rt){
        Res[par[cur]]=1;
        cur = oth(par[cur], cur);
      }
    }
    if(ask(Res)==Dist*B) r=mid;
    else l=mid+1;
  }

  return depth[Dist][l];
}

void find_pair(int _n, vector<int> U, vector<int> V, int _A, int _B){
  A=_A,B=_B;
  m = sz(U),n = _n;
  for(ll i=0;i<m;i++){
  	Xor.push_back(U[i]^V[i]);
    v[U[i]].push_back(i);
    v[V[i]].push_back(i);
  }
  Res.assign(m,0);
  Dist = ask(Res) / A;
  answer(0, (int) we_know_root(0));
}

Compilation message

highway.cpp: In function 'long long int we_know_root(long long int)':
highway.cpp:43:12: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<long long int>'
   43 |     if(ask(Res)==Dist*B) r=mid;
      |            ^~~
In file included from highway.cpp:2:
highway.h:7:39: note: in passing argument 1 of 'long long int ask(const std::vector<int>&)'
    7 | long long ask(const std::vector<int> &w);
      |               ~~~~~~~~~~~~~~~~~~~~~~~~^
highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:59:14: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<long long int>'
   59 |   Dist = ask(Res) / A;
      |              ^~~
In file included from highway.cpp:2:
highway.h:7:39: note: in passing argument 1 of 'long long int ask(const std::vector<int>&)'
    7 | long long ask(const std::vector<int> &w);
      |               ~~~~~~~~~~~~~~~~~~~~~~~~^