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 <bits/stdc++.h>
#include "highway.h"
using namespace std;
// subtask 1, 2
const int MAX_N = 9e4 + 5;
long long result;
vector <int> U, V, W;
vector <int> graph[MAX_N];
vector <int> canbeanswer;
int holdedge[MAX_N];
void dfs(int u, int p, int depth) {
if(depth == 0) {
canbeanswer.push_back(u);
return;
}
for(auto i : graph[u]) {
int v = u ^ U[i] ^ V[i];
if(v != p) {
holdedge[v] = i;
dfs(v, u, depth - 1);
}
}
}
void find_pair(int N, vector <int> u, vector <int> v, int A, int B) {
int M = u.size();
U.resize(M);
V.resize(M);
W.resize(M, 0);
for(int i = 0; i < M; i++) {
U[i] = u[i], V[i] = v[i];
graph[U[i]].push_back(i);
graph[V[i]].push_back(i);
}
result = ask(W);
int numberofEdge = result / A;
dfs(0, -1, numberofEdge);
int l = 0, r = canbeanswer.size() - 1, pos = 0;
while(l <= r) {
int mid = (l + r) / 2;
W.clear();
W.resize(M, 0);
for(int i = 0; i <= mid; i++) {
W[holdedge[canbeanswer[i]]] = 1;
}
result = ask(W);
if(result == 1ll*numberofEdge * A) {
l = mid + 1;
}
else {
r = mid - 1;
pos = mid;
}
}
answer(0, canbeanswer[pos]);
}
# | 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... |