Submission #497179

#TimeUsernameProblemLanguageResultExecution timeMemory
497179MohamedFaresNebiliHighway Tolls (IOI18_highway)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #include "highway.h" using namespace std; using ll = long long; using ii = pair<ll, ll>; using vi = vector<int>; #define pb push_back #define ff first #define ss second #define lb lower_bound #define all(x) (x).begin() , (x).end() vector<ii> adj[2*100005]; ll par[2*100005], dep[2*100005]; void dfs(ll v, ll p) { dep[v] = dep[p] + 1; for(auto u : adj[v]) { if(u.ff == p) continue; par[u.ff] = u.ss; dfs(u.ff, v); } } void find_pair(ll N, vector<ll> U, vector<ll> V, ll A, ll B) { ll M = U.size(); vector<ll> w(M, 0); ll k = ask(w); k /= A; for(ll l = 0; l < M; l++) { ll u = U[l], v = V[l]; adj[u].pb({v, l}); adj[v].pb({u, l}); } dep[0] = -1; dfs(0, 0); vector<ll> ve; for(ll l = 0; l < N; l++) { if(dep[l] != k) continue; ve.push_back(l); } for(auto u : ve) { ll id = par[u]; w[id] = 1; ll curr = ask(w); w[id] = 0; if(curr > k) { answer(0, u); return; } } }

Compilation message (stderr)

highway.cpp: In function 'void find_pair(ll, std::vector<long long int>, std::vector<long long int>, ll, ll)':
highway.cpp:27:44: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<long long int>'
   27 |             vector<ll> w(M, 0); ll k = ask(w);
      |                                            ^
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:41:42: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<long long int>'
   41 |                 w[id] = 1; ll curr = ask(w); w[id] = 0;
      |                                          ^
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);
      |               ~~~~~~~~~~~~~~~~~~~~~~~~^