//#pragma optimize("Ofast")
//#pragma optimize("unroll-loops")
//#pragma traget("avx,avx2")
//#include "highway.h"
#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
#include <cstdint>
#include <cstring>
#include <string>
#include <cstdlib>
#include <vector>
#include <bitset>
#include <map>
#include <queue>
#include <ctime>
#include <stack>
#include <set>
#include <list>
#include <random>
#include <deque>
#include <functional>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <complex>
#include <numeric>
#include <cassert>
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <thread>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define el '\n'
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define point pair <ll, ll>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using namespace std;
#include <random>
mt19937 rnd(time(0));
const int maxn = 9e4;
vector <pair <int, int>> gr[maxn];
int from[maxn], dist[maxn];
void find_pair(int n, vector <int> u, vector <int> v, int a, int b) {
int m = u.size();
vector <int> q(m);
ll len = ask(q);
int l = -1, r = m;
while (l + 1 < r) {
int mid = (l + r) >> 1;
for (int i = 0; i <= mid; i++)
q[i] = 1;
for (int i = mid + 1; i < m; i++)
q[i] = 0;
if (ask(q) == len) l = mid;
else r = mid;
}
for (int i = 0; i < m; i++)
q[i] = 1;
q[r] = 0;
for (int i = 0; i < m; i++) {
if (i == r)
continue;
gr[u[i]].pb({v[i], i});
gr[v[i]].pb({u[i], i});
}
vector <int> left, right;
for (int i = 0; i < n; i++)
from[i] = -1;
from[u[r]] = u[r];
from[v[r]] = v[r];
queue <int> qu;
qu.push(u[r]);
qu.push(v[r]);
while (!qu.empty()) {
int ver = qu.front();
qu.pop();
for (auto &[to, id] : gr[ver]) {
if (from[to] != -1)
continue;
from[to] = from[ver];
dist[to] = dist[ver] + 1;
if (from[to] == u[r]) left.pb(id);
else right.pb(id);
q[id] = 0;
qu.push(to);
}
}
vector <int> now;
int s = u[r], t = v[r];
now = q;
for (int i : left)
now[i] = 1;
ll len_left = ask(now);
l = -2, r = left.size();
while (l + 1 < r) {
int mid = (l + r) / 2;
now = q;
for (int i = 0; i <= mid; i++)
now[left[i]] = 1;
if (ask(now) == len_left) r = mid;
else l = mid;
}
if (r != -1) {
if (dist[u[left[r]]] > dist[v[left[r]]]) s = u[left[r]];
else s = v[left[r]];
}
now = q;
for (int i : right)
now[i] = 1;
ll len_right = ask(now);
l = -2, r = right.size();
while (l + 1 < r) {
int mid = (l + r) / 2;
now = q;
for (int i = 0; i <= mid; i++)
now[right[i]] = 1;
if (ask(now) == len_right) r = mid;
else l = mid;
}
if (r != -1) {
if (dist[u[right[r]]] > dist[v[right[r]]]) t = u[right[r]];
else t = v[right[r]];
}
answer(s, t);
return;
}
Compilation message
highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:66:14: error: 'ask' was not declared in this scope
66 | ll len = ask(q);
| ^~~
highway.cpp:168:5: error: 'answer' was not declared in this scope
168 | answer(s, t);
| ^~~~~~