This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "highway.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int M;
ll Ask (vector<int> v) {
vector<int> w(M);
for (int i : v) w[i] = 1;
return ask (w);
}
const int N = 2e5;
vector<pair<int,int>> g[N], mb;
void dfs (int v, ll d, int p = -1) {
for (auto [to, i] : g[v]) if (to != p) {
if (d == 1) {
mb.push_back ({to, i});
} else {
dfs (to, d-1, v);
}
}
}
void find_pair(int N, vector<int> U, vector<int> V, int A, int B) {
M = U.size();
for (int i = 0 ; i < M ; ++ i) {
g[U[i]].push_back ({V[i], i});
g[V[i]].push_back ({U[i], i});
}
ll dist = Ask ({});
if (dist < 1) while(1);
dfs (0, dist);
// if (mb.empty()) while(1);
int l = 0, r = int(mb.size()) - 1;
while (l < r) {
int m = (l + r) >> 1;
vector<int>now;
for (int i = 0 ; i <= m ; ++ i) {
now.push_back (mb[i].second);
}
if (Ask(now) > dist) {
r = m;
} else {
l = m + 1;
}
}
answer (0, mb[r].first);
}
Compilation message (stderr)
highway.cpp: In function 'void dfs(int, ll, int)':
highway.cpp:17:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
17 | for (auto [to, i] : g[v]) if (to != p) {
| ^| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |