// In The Name Of God
#include <bits/stdc++.h>
#include "highway.h"
using namespace std;
#define f first
#define s second
#define pb push_back
#define pp pop_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define nl '\n'
#define ioi exit(0);
typedef long long ll;
const int MAX_N = (int)1e5 + 7;
const int INF = (int)1e9 + 7;
int n, m, A, B;
vector < pair <int, int > > g[N];
namespace Tree {
// We suppose that S or T is 0
int depth;
ll min_len;
int dep[MAX_N];
vector <int> e;
void dfs(int v = 0, int p = -1, int lvl = 0) {
dep[v] = lvl;
for (auto to : g[v]) {
if (to.f != p) {
dfs(to.f, v, lvl + 1);
if (lvl + 1 == depth) {
e.pb(to.s);
}
}
}
}
int id(const vector <int> &x) {
if (sz(x) == 1) return x[0];
int mid = sz(x) / 2;
vector <int> q(m, 0), sol;
rep(i, 0, mid - 1) {
q[x[i]] = 1;
sol.pb(x[i]);
}
ll cur = ask(q);
if (cur > min_len) return id(sol);
vector <int> on;
rep(i, mid, sz(x) - 1) on.pn(x[i]);
return id(on);
}
void solve() {
if (n != m + 1) return;
{
vector <int> q(m, 0);
min_len = ask(q);
depth = min_len / A;
}
int ed = id(e);
rep(i, 0, n - 1) {
for (auto it : g[i]) {
if (it.s == ed) {
if (dep[i] > dep[it.f]) answer(0, i);
else answer(0. it.f);
ioi
}
}
}
assert(0);
}
}
void find_pair(int N, vector<int> U, vector<int> V, int _A, int _B) {
n = N;
m = sz(U);
A = _A;
B = _B;
rep(i, 0, m - 1) {
g[V[i]].pb({U[i], i});
g[U[i]].pb({V[i], i});
}
// copy finished
Tree :: solve();
answer(0, N - 1);
}
Compilation message
highway.cpp:30:31: error: 'N' was not declared in this scope
vector < pair <int, int > > g[N];
^
highway.cpp: In function 'void Tree::dfs(int, int, int)':
highway.cpp:42:18: error: 'g' was not declared in this scope
for (auto to : g[v]) {
^
highway.cpp: In function 'int Tree::id(const std::vector<int>&)':
highway.cpp:66:29: error: 'class std::vector<int>' has no member named 'pn'
rep(i, mid, sz(x) - 1) on.pn(x[i]);
^~
highway.cpp: In function 'void Tree::solve()':
highway.cpp:80:19: error: 'g' was not declared in this scope
for (auto it : g[i]) {
^
highway.cpp:83:21: error: expected ')' before 'it'
else answer(0. it.f);
^~
highway.cpp:83:25: error: too few arguments to function 'void answer(int, int)'
else answer(0. it.f);
^
In file included from highway.cpp:4:0:
highway.h:8:6: note: declared here
void answer(int s, int t);
^~~~~~
highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:98:4: error: 'g' was not declared in this scope
g[V[i]].pb({U[i], i});
^