#include "highway.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 10;
vector<int> Q;
ll Cost = 0;
int p[maxn], par[maxn];
vector<pair<int,int>> g[maxn];
bool mark[maxn];
int Que[maxn], head = 0, tail = 0, h[maxn];
int n;
int Get(int v){
memset(h, -1, sizeof h);
tail = head = 0;
h[v] = 0, Que[head++] = v;
while (tail < head){
int v = Que[tail++];
for (auto [u,idx] : g[v])
if (h[u] == -1)
h[u] = h[v]+1, Que[head++] = u;
}
for (int i = 0; i < n; i++)
p[i] = i;
sort(p, p+n, [](int A, int B){
return h[A] > h[B];
});
int L = -1, R = n-1;
while (R-L > 1){
int mid = (L+R) >> 1;
for (int i = 0; i <= mid; i++){
int v = p[i];
for (auto [u,idx] : g[v])
Q[idx] |= 1;
}
ll nowCost = ask(Q);
for (int i = 0; i <= mid; i++){
int v = p[i];
for (auto [u,idx] : g[v])
Q[idx] &= 0;
}
if (nowCost == Cost)
L = mid;
else
R = mid;
}
return p[R];
}
void find_pair(int n, vector<int> U, vector<int> V, int A, int B) {
::n = n;
int m = U.size();
Q.resize(m);
for (int i = 0; i < m; i++){
Q[i] = 0;
g[V[i]].push_back({U[i],i});
g[U[i]].push_back({V[i],i});
}
Cost = ask(Q);
int v = Get(0);
int S = Get(v);
int T = Get(S);
answer(S,T);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
5760 KB |
Output is correct |
2 |
Correct |
4 ms |
5760 KB |
Output is correct |
3 |
Correct |
4 ms |
5760 KB |
Output is correct |
4 |
Correct |
4 ms |
5760 KB |
Output is correct |
5 |
Correct |
4 ms |
5760 KB |
Output is correct |
6 |
Correct |
4 ms |
5760 KB |
Output is correct |
7 |
Correct |
5 ms |
5760 KB |
Output is correct |
8 |
Correct |
5 ms |
5868 KB |
Output is correct |
9 |
Correct |
4 ms |
5760 KB |
Output is correct |
10 |
Correct |
4 ms |
5856 KB |
Output is correct |
11 |
Correct |
5 ms |
5888 KB |
Output is correct |
12 |
Correct |
5 ms |
5760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
6016 KB |
Output is correct |
2 |
Correct |
53 ms |
6392 KB |
Output is correct |
3 |
Correct |
699 ms |
11764 KB |
Output is correct |
4 |
Correct |
540 ms |
11896 KB |
Output is correct |
5 |
Correct |
547 ms |
11880 KB |
Output is correct |
6 |
Correct |
308 ms |
11736 KB |
Output is correct |
7 |
Correct |
859 ms |
11868 KB |
Output is correct |
8 |
Correct |
833 ms |
11776 KB |
Output is correct |
9 |
Correct |
873 ms |
11740 KB |
Output is correct |
10 |
Correct |
471 ms |
11788 KB |
Output is correct |
11 |
Correct |
955 ms |
11196 KB |
Output is correct |
12 |
Correct |
773 ms |
11340 KB |
Output is correct |
13 |
Correct |
823 ms |
11168 KB |
Output is correct |
14 |
Correct |
514 ms |
11392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
6400 KB |
Output is correct |
2 |
Correct |
42 ms |
7120 KB |
Output is correct |
3 |
Correct |
63 ms |
7628 KB |
Output is correct |
4 |
Correct |
183 ms |
11260 KB |
Output is correct |
5 |
Correct |
258 ms |
11300 KB |
Output is correct |
6 |
Correct |
158 ms |
11180 KB |
Output is correct |
7 |
Correct |
183 ms |
11256 KB |
Output is correct |
8 |
Correct |
168 ms |
11188 KB |
Output is correct |
9 |
Correct |
235 ms |
11224 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
5888 KB |
Output is correct |
2 |
Correct |
33 ms |
6400 KB |
Output is correct |
3 |
Correct |
770 ms |
10616 KB |
Output is correct |
4 |
Correct |
926 ms |
11824 KB |
Output is correct |
5 |
Correct |
853 ms |
11768 KB |
Output is correct |
6 |
Correct |
704 ms |
11764 KB |
Output is correct |
7 |
Correct |
697 ms |
11812 KB |
Output is correct |
8 |
Correct |
929 ms |
11716 KB |
Output is correct |
9 |
Correct |
510 ms |
11784 KB |
Output is correct |
10 |
Correct |
945 ms |
11752 KB |
Output is correct |
11 |
Correct |
669 ms |
11360 KB |
Output is correct |
12 |
Correct |
406 ms |
11172 KB |
Output is correct |
13 |
Correct |
581 ms |
11196 KB |
Output is correct |
14 |
Correct |
849 ms |
11172 KB |
Output is correct |
15 |
Correct |
1064 ms |
11728 KB |
Output is correct |
16 |
Correct |
836 ms |
11748 KB |
Output is correct |
17 |
Correct |
540 ms |
11320 KB |
Output is correct |
18 |
Correct |
973 ms |
11268 KB |
Output is correct |
19 |
Correct |
1122 ms |
11876 KB |
Output is correct |
20 |
Correct |
928 ms |
11232 KB |
Output is correct |
21 |
Correct |
429 ms |
11964 KB |
Output is correct |
22 |
Correct |
348 ms |
12168 KB |
Output is correct |
23 |
Correct |
386 ms |
11944 KB |
Output is correct |
24 |
Correct |
260 ms |
11936 KB |
Output is correct |
25 |
Correct |
296 ms |
11360 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
6528 KB |
Output is correct |
2 |
Correct |
32 ms |
6528 KB |
Output is correct |
3 |
Correct |
536 ms |
12076 KB |
Output is correct |
4 |
Correct |
656 ms |
12616 KB |
Output is correct |
5 |
Correct |
838 ms |
13460 KB |
Output is correct |
6 |
Correct |
672 ms |
13592 KB |
Output is correct |
7 |
Correct |
843 ms |
13512 KB |
Output is correct |
8 |
Correct |
454 ms |
13516 KB |
Output is correct |
9 |
Correct |
273 ms |
11528 KB |
Output is correct |
10 |
Correct |
293 ms |
12116 KB |
Output is correct |
11 |
Correct |
357 ms |
12168 KB |
Output is correct |
12 |
Correct |
658 ms |
13236 KB |
Output is correct |
13 |
Correct |
618 ms |
13328 KB |
Output is correct |
14 |
Correct |
685 ms |
13620 KB |
Output is correct |
15 |
Correct |
670 ms |
13464 KB |
Output is correct |
16 |
Correct |
460 ms |
12580 KB |
Output is correct |
17 |
Correct |
382 ms |
12048 KB |
Output is correct |
18 |
Correct |
223 ms |
12268 KB |
Output is correct |
19 |
Correct |
256 ms |
12088 KB |
Output is correct |
20 |
Correct |
278 ms |
12076 KB |
Output is correct |
21 |
Correct |
1411 ms |
13668 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
6528 KB |
Output is correct |
2 |
Correct |
23 ms |
6528 KB |
Output is correct |
3 |
Correct |
923 ms |
12160 KB |
Output is correct |
4 |
Partially correct |
674 ms |
12488 KB |
Output is partially correct |
5 |
Partially correct |
426 ms |
12612 KB |
Output is partially correct |
6 |
Correct |
869 ms |
13764 KB |
Output is correct |
7 |
Partially correct |
543 ms |
12132 KB |
Output is partially correct |
8 |
Correct |
886 ms |
12316 KB |
Output is correct |
9 |
Partially correct |
744 ms |
12712 KB |
Output is partially correct |
10 |
Partially correct |
724 ms |
13524 KB |
Output is partially correct |
11 |
Correct |
908 ms |
13560 KB |
Output is correct |
12 |
Correct |
725 ms |
13572 KB |
Output is correct |
13 |
Correct |
297 ms |
12224 KB |
Output is correct |
14 |
Correct |
343 ms |
12112 KB |
Output is correct |
15 |
Correct |
484 ms |
12280 KB |
Output is correct |
16 |
Correct |
406 ms |
12196 KB |
Output is correct |
17 |
Correct |
292 ms |
12300 KB |
Output is correct |
18 |
Correct |
229 ms |
12088 KB |
Output is correct |
19 |
Correct |
620 ms |
13160 KB |
Output is correct |
20 |
Correct |
940 ms |
13352 KB |
Output is correct |
21 |
Partially correct |
971 ms |
13584 KB |
Output is partially correct |
22 |
Correct |
529 ms |
13548 KB |
Output is correct |
23 |
Partially correct |
477 ms |
13572 KB |
Output is partially correct |
24 |
Correct |
607 ms |
13548 KB |
Output is correct |
25 |
Correct |
947 ms |
13604 KB |
Output is correct |
26 |
Correct |
936 ms |
13660 KB |
Output is correct |
27 |
Correct |
514 ms |
12112 KB |
Output is correct |
28 |
Partially correct |
297 ms |
12096 KB |
Output is partially correct |
29 |
Correct |
402 ms |
12592 KB |
Output is correct |
30 |
Correct |
333 ms |
12104 KB |
Output is correct |
31 |
Correct |
351 ms |
12200 KB |
Output is correct |
32 |
Partially correct |
246 ms |
12192 KB |
Output is partially correct |
33 |
Correct |
360 ms |
12376 KB |
Output is correct |
34 |
Partially correct |
382 ms |
12024 KB |
Output is partially correct |
35 |
Correct |
491 ms |
12044 KB |
Output is correct |
36 |
Partially correct |
276 ms |
11940 KB |
Output is partially correct |
37 |
Correct |
271 ms |
12328 KB |
Output is correct |
38 |
Partially correct |
310 ms |
12280 KB |
Output is partially correct |
39 |
Partially correct |
1197 ms |
13656 KB |
Output is partially correct |
40 |
Correct |
1216 ms |
13640 KB |
Output is correct |
41 |
Partially correct |
414 ms |
13652 KB |
Output is partially correct |
42 |
Correct |
1198 ms |
13644 KB |
Output is correct |