Submission #501394

#TimeUsernameProblemLanguageResultExecution timeMemory
501394sidonHighway Tolls (IOI18_highway)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; void find_pair(int N, vector<int> U, vector<int> V, int A, int B) { int M = size(U), x = 0, u; ll least = ask(vector<int> (M)), d[2][N]; for(int b = 1<<17; b/=2; ) if(x + b < M) { vector<int> w(M); fill(begin(w), begin(w) + x + b, 1); if(ask(w) == least) x |= b; } array<int, 2> S = {U[x], V[x]}, ans {}; vector<array<int, 2>> g[N]; vector<int> ord[2], a; for(int i = x; i < M; i++) { g[U[i]].push_back({V[i], i}); g[V[i]].push_back({U[i], i}); } for(int k : {0, 1}) { fill(d[k], d[k] + N, 1e18); queue<int> q; d[k][S[k]] = 0; q.push(S[k]); while(!empty(q)) { ord[k].push_back(u = q.front()); q.pop(); for(auto &[v, e] : g[u]) if(d[k][v] > d[k][u] + 1) d[k][v] = d[k][u] + 1, q.push(v); } } for(int k : {0, 1}) { a.clear(); for(int i : ord[k]) if(d[k][i] < d[!k][i]) a.push_back(i); for(int b = 1<<17; b/=2; ) if(ans[k] + b < size(a)) { vector<int> w(M); fill(begin(w), begin(w) + x, 1); for(int i = ans[k] + b; --i >= 0; ) for(auto &[v, e] : g[a[size(a)-ans[k]-b]]) w[e] = 1; if(ask(w) == least) ans[k] |= b; } ans[k] = a[size(a)-1-ans[k]]; } answer(ans[0], ans[1]); }

Compilation message (stderr)

highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:7:13: error: 'ask' was not declared in this scope
    7 |  ll least = ask(vector<int> (M)), d[2][N];
      |             ^~~
highway.cpp:25:8: error: 'd' was not declared in this scope
   25 |   fill(d[k], d[k] + N, 1e18);
      |        ^
highway.cpp:41:7: error: 'd' was not declared in this scope
   41 |    if(d[k][i] < d[!k][i]) a.push_back(i);
      |       ^
highway.cpp:43:44: warning: comparison of integer expressions of different signedness: 'std::array<int, 2>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |   for(int b = 1<<17; b/=2; ) if(ans[k] + b < size(a)) {
highway.cpp:56:2: error: 'answer' was not declared in this scope
   56 |  answer(ans[0], ans[1]);
      |  ^~~~~~