#include "highway.h"
#include <cstdio>
#include <algorithm>
#define N_ 101000
using namespace std;
int n, m, Q[N_], head, tail, par[N_], vis[N_], pN[N_], vv[N_];
vector<int>T, E[N_];
void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) {
int i;
n = N;
m = U.size();
T.resize(m);
for (i = 0; i < m; i++) {
T[i] = 0;
E[U[i]].push_back(V[i]);
E[V[i]].push_back(U[i]);
}
int L = ask(T);
int b = 0, e = n - 2, mid, r = n - 1;
while (b <= e) {
mid = (b + e) >> 1;
for (i = 0; i < m; i++) {
if (U[i] > mid || V[i] > mid)T[i] = 1;
else T[i] = 0;
}
if (ask(T) == L)r = mid, e = mid - 1;
else b = mid + 1;
}
int root = r;
Q[++tail] = root, vis[root] = 1;
par[root] = -1;
while (head < tail) {
int x = Q[++head];
for (auto &y : E[x]) {
if (!vis[y]) {
vis[y] = 1;
Q[++tail] = y;
par[y] = x;
}
}
}
for (i = 0; i < m; i++) {
if (par[U[i]] == V[i])pN[U[i]] = i;
if (par[V[i]] == U[i])pN[V[i]] = i;
}
b = 1, e = tail - 1, r = tail;
while (b <= e) {
mid = (b + e) >> 1;
for (i = 0; i < m; i++)T[i] = 1;
for (i = 2; i <= mid; i++) T[pN[Q[i]]] = 0;
if (ask(T) == L)r = mid, e = mid - 1;
else b = mid + 1;
}
int ed = Q[r];
int tp = ed;
while (tp != root) {
vv[pN[tp]] = 1;
tp = par[tp];
}
b = 1, e = r - 1;
while (b <= e) {
mid = (b + e) >> 1;
for (i = 0; i < m; i++) {
if(!vv[i])T[i] = 1;
}
for (i = 2; i <= mid; i++) T[pN[Q[i]]] = 0;
if (ask(T) == L)r = mid, e = mid - 1;
else b = mid + 1;
}
int st = Q[r];
answer(st, ed);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
2680 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
2680 KB |
Output is correct |
2 |
Correct |
17 ms |
3392 KB |
Output is correct |
3 |
Correct |
216 ms |
8864 KB |
Output is correct |
4 |
Incorrect |
270 ms |
8860 KB |
Output is incorrect: {s, t} is wrong. |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
3368 KB |
Output is correct |
2 |
Correct |
41 ms |
4044 KB |
Output is correct |
3 |
Incorrect |
57 ms |
4704 KB |
Output is incorrect: {s, t} is wrong. |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
2680 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
28 ms |
3400 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
3392 KB |
Output is correct |
2 |
Incorrect |
42 ms |
3420 KB |
Output is incorrect: {s, t} is wrong. |
3 |
Halted |
0 ms |
0 KB |
- |