#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]);
}
long long 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;
else T[i] = 0;
}
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 |
Correct |
4 ms |
2688 KB |
Output is correct |
2 |
Correct |
4 ms |
2772 KB |
Output is correct |
3 |
Correct |
4 ms |
2680 KB |
Output is correct |
4 |
Correct |
4 ms |
2692 KB |
Output is correct |
5 |
Correct |
4 ms |
2724 KB |
Output is correct |
6 |
Correct |
4 ms |
2680 KB |
Output is correct |
7 |
Correct |
4 ms |
2680 KB |
Output is correct |
8 |
Correct |
5 ms |
2768 KB |
Output is correct |
9 |
Correct |
4 ms |
2680 KB |
Output is correct |
10 |
Correct |
4 ms |
2600 KB |
Output is correct |
11 |
Correct |
4 ms |
2680 KB |
Output is correct |
12 |
Correct |
4 ms |
2680 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
2732 KB |
Output is correct |
2 |
Correct |
37 ms |
3380 KB |
Output is correct |
3 |
Correct |
239 ms |
8888 KB |
Output is correct |
4 |
Correct |
263 ms |
8860 KB |
Output is correct |
5 |
Correct |
245 ms |
8872 KB |
Output is correct |
6 |
Correct |
239 ms |
8908 KB |
Output is correct |
7 |
Correct |
213 ms |
8856 KB |
Output is correct |
8 |
Correct |
204 ms |
8832 KB |
Output is correct |
9 |
Correct |
197 ms |
8908 KB |
Output is correct |
10 |
Correct |
264 ms |
8908 KB |
Output is correct |
11 |
Correct |
220 ms |
9064 KB |
Output is correct |
12 |
Correct |
228 ms |
9136 KB |
Output is correct |
13 |
Correct |
303 ms |
9060 KB |
Output is correct |
14 |
Correct |
246 ms |
9056 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
3360 KB |
Output is correct |
2 |
Correct |
37 ms |
4044 KB |
Output is correct |
3 |
Correct |
69 ms |
4700 KB |
Output is correct |
4 |
Correct |
185 ms |
8776 KB |
Output is correct |
5 |
Correct |
166 ms |
8704 KB |
Output is correct |
6 |
Correct |
171 ms |
8924 KB |
Output is correct |
7 |
Correct |
155 ms |
8700 KB |
Output is correct |
8 |
Correct |
157 ms |
8856 KB |
Output is correct |
9 |
Correct |
166 ms |
8844 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
2824 KB |
Output is correct |
2 |
Correct |
24 ms |
3372 KB |
Output is correct |
3 |
Correct |
163 ms |
7480 KB |
Output is correct |
4 |
Correct |
205 ms |
8836 KB |
Output is correct |
5 |
Correct |
202 ms |
8816 KB |
Output is correct |
6 |
Correct |
180 ms |
8812 KB |
Output is correct |
7 |
Correct |
180 ms |
8904 KB |
Output is correct |
8 |
Correct |
199 ms |
8816 KB |
Output is correct |
9 |
Correct |
238 ms |
8848 KB |
Output is correct |
10 |
Correct |
231 ms |
8860 KB |
Output is correct |
11 |
Correct |
247 ms |
9160 KB |
Output is correct |
12 |
Correct |
214 ms |
9072 KB |
Output is correct |
13 |
Correct |
260 ms |
9060 KB |
Output is correct |
14 |
Correct |
234 ms |
9096 KB |
Output is correct |
15 |
Correct |
191 ms |
8812 KB |
Output is correct |
16 |
Correct |
193 ms |
8836 KB |
Output is correct |
17 |
Correct |
249 ms |
9044 KB |
Output is correct |
18 |
Correct |
219 ms |
9076 KB |
Output is correct |
19 |
Correct |
197 ms |
8920 KB |
Output is correct |
20 |
Correct |
207 ms |
9252 KB |
Output is correct |
21 |
Correct |
210 ms |
9152 KB |
Output is correct |
22 |
Correct |
201 ms |
9072 KB |
Output is correct |
23 |
Correct |
225 ms |
9412 KB |
Output is correct |
24 |
Correct |
232 ms |
9512 KB |
Output is correct |
25 |
Correct |
263 ms |
9120 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
3388 KB |
Output is correct |
2 |
Correct |
23 ms |
3408 KB |
Output is correct |
3 |
Correct |
249 ms |
9084 KB |
Output is correct |
4 |
Correct |
262 ms |
9380 KB |
Output is correct |
5 |
Incorrect |
269 ms |
9792 KB |
Output is incorrect: {s, t} is wrong. |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
51 ms |
3352 KB |
Output is correct |
2 |
Correct |
31 ms |
3416 KB |
Output is correct |
3 |
Correct |
242 ms |
9136 KB |
Output is correct |
4 |
Correct |
259 ms |
9340 KB |
Output is correct |
5 |
Correct |
295 ms |
9296 KB |
Output is correct |
6 |
Correct |
324 ms |
9804 KB |
Output is correct |
7 |
Correct |
219 ms |
9076 KB |
Output is correct |
8 |
Correct |
230 ms |
9160 KB |
Output is correct |
9 |
Incorrect |
249 ms |
9292 KB |
Output is incorrect: {s, t} is wrong. |
10 |
Halted |
0 ms |
0 KB |
- |