#include "highway.h"
#include "bits/stdc++.h"
using namespace std;
int n, m;
vector<int> pe;
vector<int> dep;
vector<vector<pair<int,int>>> g;
void Dfs (int v, int p) {
for (auto [u, i] : g[v]) {
if (u == p) {
continue;
}
pe[u] = i;
dep[u] = dep[v] + 1;
Dfs(u, v);
}
}
void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) {
n = N;
g.resize(n);
pe.resize(n);
dep.resize(n);
m = (int) 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});
}
Dfs(0, 0);
vector<int> vec;
vector<int> w(m, 0);
int dis = ask(w);
int depT = dis / A;
assert(depT != 0);
for (int i = 0; i < n; ++i) {
if (dep[i] == depT) {
vec.push_back(i);
}
}
auto fix = [&](vector<int> nodes) {
vector<int> ret(m);
for (int u : nodes) {
ret[pe[u]] = true;
}
return ret;
};
while (vec.size() > 1) {
vector<int> lx, rx;
int mid = (int) vec.size() / 2;
for (int i = 0; i < mid; ++i) {
lx.push_back(vec[i]);
}
for (int i = mid; i < (int) vec.size(); ++i) {
rx.push_back(vec[i]);
}
if (ask(fix(lx)) > dis) {
vec = lx;
} else {
vec = rx;
}
}
assert(!vec.empty());
answer(0, vec[0]);//S, T
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
0 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
208 KB |
Output is correct |
12 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
7 ms |
1232 KB |
Output is correct |
3 |
Correct |
74 ms |
8728 KB |
Output is correct |
4 |
Correct |
81 ms |
8700 KB |
Output is correct |
5 |
Correct |
60 ms |
8716 KB |
Output is correct |
6 |
Correct |
60 ms |
8632 KB |
Output is correct |
7 |
Correct |
77 ms |
8668 KB |
Output is correct |
8 |
Correct |
77 ms |
8684 KB |
Output is correct |
9 |
Correct |
96 ms |
8668 KB |
Output is correct |
10 |
Correct |
100 ms |
8676 KB |
Output is correct |
11 |
Correct |
78 ms |
9084 KB |
Output is correct |
12 |
Correct |
63 ms |
9472 KB |
Output is correct |
13 |
Correct |
84 ms |
9144 KB |
Output is correct |
14 |
Incorrect |
89 ms |
8672 KB |
Output is incorrect: {s, t} is wrong. |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
1488 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
193 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
183 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |