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"
typedef long long int64;
using namespace std;
const int maxn = 9e4 + 2;
const int maxm = 13e4 + 2;
vector <pair <int, int> > ad [maxn];
vector <int> w;
int n;
int64 len, a, b, lastlen = 1e9;
bool done = 0;
void dfs (int u, int p, int64 d = 0) {
if (done || u > lastlen) return;
if (d == len) {
lastlen = ask(w) / b;
if (lastlen == len){
answer(0, u);
done = 1;
}
return;
}
for (pair <int, int> v: ad[u]) {
if (v.first == p) continue;
w[v.second] = 1;
dfs(v.first, u, d + 1);
if (lastlen == d) lastlen = 1e9;
w[v.second] = 0;
}
}
void find_pair(int N, vector<int> u, vector<int> v, int A, int B) {
int m = u.size();
n = N, a = A, b = B;
for (int i = 0; i < m; i++){
ad[u[i]].push_back({v[i], i});
ad[v[i]].push_back({u[i], i});
}
for (int i = 0; i < m; i++){
w.push_back(0);
}
len = ask(w) / a;
dfs(0, -1);
assert(done);
}
# | 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... |