#include<bits/stdc++.h>
#include "highway.h"
using namespace std;
struct Edge
{
int b,c;
};
vector<Edge>D[90009];
int n,m;
long long DeafOdl;
vector<int>EE1,EE2;
int O1[90009],O2[90009];
vector<int>BFS(int s, int *O)
{
memset(O,-1,sizeof(O1));
O[s]=0;
deque<int>Y={s};
vector<int>W;
while((int)Y.size()>0)
{
const int v=Y[0];
Y.pop_front();
W.push_back(v);
for(auto[som,ind] : D[v])
{
if(O[som]==-1)
{
O[som]=O[v]+1;
Y.push_back(som);
}
}
}
return W;
}
int BinSearch()
{
int l=0,p=m-1;
while(l<p)
{
const int mid=(l+p+1)>>1;
vector<int>Query(m);
for(int i=mid;i<m;i++)
{
Query[i]=1;
}
if(ask(Query)!=DeafOdl)
{
l=mid;
}
else
{
p=mid-1;
}
}
return l;
}
int BinSearch2(int s, vector<int>W)
{
int l=0,p=W.size()-1;
while(l<p)
{
const int mid=(l+p+1)>>1;
vector<int>Query(m);
for(int i=mid;i<(int)W.size();i++)
{
for(auto[som,ind] : D[W[i]])
{
Query[ind]=1;
}
}
if(ask(Query)!=DeafOdl)
{
l=mid;
}
else
{
p=mid-1;
}
}
return W[l];
}
void find_pair(int N, vector<int>E1, vector<int>E2, int uA, int uB)
{
n=N;
m=E1.size();
EE1=E1;
EE2=E2;
for(int i=0;i<m;i++)
{
D[E1[i]].push_back({E2[i],i});
D[E2[i]].push_back({E1[i],i});
}
DeafOdl=ask(vector<int>(m));
int u=BinSearch();
int aa=EE1[u],bb=EE2[u];
vector<int>AA=BFS(aa,O1);
vector<int>BB=BFS(bb,O2);
vector<int>A,B;
for(int u : AA)
{
if(O1[u]+1==O2[u]){A.push_back(u);}
}
for(int u : BB)
{
if(O2[u]+1==O1[u]){B.push_back(u);}
}
int a=BinSearch2(aa,A);
int b=BinSearch2(bb,B);
if(a>b){swap(a,b);}
//cout<<"a="<<a<<" b="<<b<<" u="<<u<<" DeafOdl="<<DeafOdl<<endl;
answer(a,b);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3160 KB |
Output is correct |
2 |
Correct |
2 ms |
3160 KB |
Output is correct |
3 |
Correct |
2 ms |
3160 KB |
Output is correct |
4 |
Correct |
2 ms |
3160 KB |
Output is correct |
5 |
Correct |
1 ms |
3160 KB |
Output is correct |
6 |
Correct |
2 ms |
3160 KB |
Output is correct |
7 |
Correct |
2 ms |
3160 KB |
Output is correct |
8 |
Correct |
2 ms |
3160 KB |
Output is correct |
9 |
Correct |
2 ms |
3160 KB |
Output is correct |
10 |
Correct |
2 ms |
3160 KB |
Output is correct |
11 |
Correct |
2 ms |
3160 KB |
Output is correct |
12 |
Correct |
2 ms |
3160 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3160 KB |
Output is correct |
2 |
Correct |
10 ms |
3928 KB |
Output is correct |
3 |
Correct |
98 ms |
10544 KB |
Output is correct |
4 |
Correct |
90 ms |
10552 KB |
Output is correct |
5 |
Correct |
98 ms |
10540 KB |
Output is correct |
6 |
Correct |
78 ms |
10520 KB |
Output is correct |
7 |
Correct |
96 ms |
10564 KB |
Output is correct |
8 |
Correct |
94 ms |
10796 KB |
Output is correct |
9 |
Correct |
97 ms |
10628 KB |
Output is correct |
10 |
Correct |
84 ms |
10544 KB |
Output is correct |
11 |
Correct |
106 ms |
10100 KB |
Output is correct |
12 |
Correct |
102 ms |
10264 KB |
Output is correct |
13 |
Correct |
94 ms |
9948 KB |
Output is correct |
14 |
Correct |
100 ms |
9952 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
3928 KB |
Output is correct |
2 |
Correct |
16 ms |
4640 KB |
Output is correct |
3 |
Correct |
25 ms |
5684 KB |
Output is correct |
4 |
Correct |
69 ms |
9908 KB |
Output is correct |
5 |
Correct |
70 ms |
9980 KB |
Output is correct |
6 |
Correct |
67 ms |
9836 KB |
Output is correct |
7 |
Correct |
62 ms |
9984 KB |
Output is correct |
8 |
Correct |
70 ms |
9928 KB |
Output is correct |
9 |
Correct |
70 ms |
10044 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3160 KB |
Output is correct |
2 |
Correct |
10 ms |
3976 KB |
Output is correct |
3 |
Correct |
85 ms |
8944 KB |
Output is correct |
4 |
Correct |
100 ms |
10524 KB |
Output is correct |
5 |
Correct |
86 ms |
10536 KB |
Output is correct |
6 |
Correct |
88 ms |
10532 KB |
Output is correct |
7 |
Correct |
92 ms |
10540 KB |
Output is correct |
8 |
Correct |
95 ms |
10524 KB |
Output is correct |
9 |
Correct |
98 ms |
10576 KB |
Output is correct |
10 |
Correct |
94 ms |
10544 KB |
Output is correct |
11 |
Correct |
92 ms |
9964 KB |
Output is correct |
12 |
Correct |
91 ms |
10080 KB |
Output is correct |
13 |
Correct |
101 ms |
10000 KB |
Output is correct |
14 |
Correct |
97 ms |
10084 KB |
Output is correct |
15 |
Correct |
93 ms |
10724 KB |
Output is correct |
16 |
Correct |
92 ms |
10540 KB |
Output is correct |
17 |
Correct |
95 ms |
9952 KB |
Output is correct |
18 |
Correct |
84 ms |
9968 KB |
Output is correct |
19 |
Correct |
110 ms |
10552 KB |
Output is correct |
20 |
Correct |
92 ms |
9976 KB |
Output is correct |
21 |
Correct |
73 ms |
11460 KB |
Output is correct |
22 |
Correct |
70 ms |
11460 KB |
Output is correct |
23 |
Correct |
84 ms |
10952 KB |
Output is correct |
24 |
Correct |
78 ms |
10640 KB |
Output is correct |
25 |
Correct |
89 ms |
9944 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
3928 KB |
Output is correct |
2 |
Correct |
11 ms |
4268 KB |
Output is correct |
3 |
Correct |
107 ms |
11228 KB |
Output is correct |
4 |
Correct |
111 ms |
11516 KB |
Output is correct |
5 |
Correct |
131 ms |
12684 KB |
Output is correct |
6 |
Correct |
143 ms |
12700 KB |
Output is correct |
7 |
Correct |
150 ms |
12576 KB |
Output is correct |
8 |
Correct |
140 ms |
12564 KB |
Output is correct |
9 |
Correct |
94 ms |
10484 KB |
Output is correct |
10 |
Correct |
100 ms |
10808 KB |
Output is correct |
11 |
Correct |
106 ms |
11296 KB |
Output is correct |
12 |
Correct |
137 ms |
12252 KB |
Output is correct |
13 |
Correct |
127 ms |
12432 KB |
Output is correct |
14 |
Correct |
136 ms |
12732 KB |
Output is correct |
15 |
Correct |
131 ms |
12672 KB |
Output is correct |
16 |
Correct |
137 ms |
11372 KB |
Output is correct |
17 |
Correct |
87 ms |
10768 KB |
Output is correct |
18 |
Correct |
81 ms |
10952 KB |
Output is correct |
19 |
Correct |
91 ms |
10856 KB |
Output is correct |
20 |
Correct |
86 ms |
10952 KB |
Output is correct |
21 |
Correct |
147 ms |
12896 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
3928 KB |
Output is correct |
2 |
Correct |
11 ms |
4184 KB |
Output is correct |
3 |
Correct |
100 ms |
11052 KB |
Output is correct |
4 |
Correct |
121 ms |
11364 KB |
Output is correct |
5 |
Correct |
118 ms |
11460 KB |
Output is correct |
6 |
Correct |
144 ms |
12748 KB |
Output is correct |
7 |
Correct |
112 ms |
11056 KB |
Output is correct |
8 |
Correct |
119 ms |
11176 KB |
Output is correct |
9 |
Correct |
107 ms |
11540 KB |
Output is correct |
10 |
Correct |
138 ms |
12892 KB |
Output is correct |
11 |
Correct |
129 ms |
12536 KB |
Output is correct |
12 |
Correct |
149 ms |
12668 KB |
Output is correct |
13 |
Correct |
101 ms |
11308 KB |
Output is correct |
14 |
Correct |
104 ms |
11044 KB |
Output is correct |
15 |
Correct |
125 ms |
11160 KB |
Output is correct |
16 |
Correct |
91 ms |
10780 KB |
Output is correct |
17 |
Correct |
103 ms |
11148 KB |
Output is correct |
18 |
Correct |
104 ms |
10904 KB |
Output is correct |
19 |
Correct |
135 ms |
12144 KB |
Output is correct |
20 |
Correct |
139 ms |
12416 KB |
Output is correct |
21 |
Correct |
148 ms |
12604 KB |
Output is correct |
22 |
Correct |
132 ms |
12564 KB |
Output is correct |
23 |
Correct |
143 ms |
12520 KB |
Output is correct |
24 |
Correct |
133 ms |
12560 KB |
Output is correct |
25 |
Correct |
137 ms |
12728 KB |
Output is correct |
26 |
Correct |
130 ms |
12636 KB |
Output is correct |
27 |
Correct |
79 ms |
10896 KB |
Output is correct |
28 |
Correct |
100 ms |
10808 KB |
Output is correct |
29 |
Correct |
92 ms |
11048 KB |
Output is correct |
30 |
Correct |
82 ms |
10908 KB |
Output is correct |
31 |
Correct |
84 ms |
10840 KB |
Output is correct |
32 |
Correct |
77 ms |
10756 KB |
Output is correct |
33 |
Correct |
83 ms |
11064 KB |
Output is correct |
34 |
Correct |
75 ms |
10880 KB |
Output is correct |
35 |
Correct |
87 ms |
11028 KB |
Output is correct |
36 |
Correct |
93 ms |
10736 KB |
Output is correct |
37 |
Correct |
93 ms |
10972 KB |
Output is correct |
38 |
Correct |
87 ms |
11076 KB |
Output is correct |
39 |
Correct |
144 ms |
12640 KB |
Output is correct |
40 |
Correct |
146 ms |
12756 KB |
Output is correct |
41 |
Correct |
118 ms |
12688 KB |
Output is correct |
42 |
Correct |
153 ms |
12636 KB |
Output is correct |