#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>DeafQuery;
vector<int>BFS(int s)
{
vector<int>ODL(n,-1);
ODL[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(ODL[som]==-1)
{
ODL[som]=ODL[v]+1;
Y.push_back(som);
}
}
}
return W;
}
int BinSearch()
{
int l=0,p=n-1;
while(l<p)
{
const int mid=(l+p+1)>>1;
vector<int>Query(m);
for(int i=mid;i<n;i++)
{
for(auto[som,ind] : D[i])
{
Query[ind]=1;
}
}
if(ask(Query)!=DeafOdl)
{
l=mid;
}
else
{
p=mid-1;
}
}
return l;
}
int BinSearch2(int s)
{
vector<int>W=BFS(s);
int l=0,p=n-1;
while(l<p)
{
const int mid=(l+p+1)>>1;
vector<int>Query=DeafQuery;
for(int i=mid;i<n;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 A, int B)
{
n=N;
m=E1.size();
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();
DeafQuery.resize(m);
for(int i=u+1;i<n;i++)
{
for(auto[som,ind] : D[i])
{
DeafQuery[ind]=1;
}
}
int a=BinSearch2(u);
int b=BinSearch2(a);
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 |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
2 ms |
2392 KB |
Output is correct |
3 |
Correct |
1 ms |
2392 KB |
Output is correct |
4 |
Correct |
2 ms |
2392 KB |
Output is correct |
5 |
Correct |
1 ms |
2392 KB |
Output is correct |
6 |
Correct |
1 ms |
2392 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
1 ms |
2392 KB |
Output is correct |
9 |
Correct |
1 ms |
2392 KB |
Output is correct |
10 |
Correct |
1 ms |
2392 KB |
Output is correct |
11 |
Correct |
1 ms |
2392 KB |
Output is correct |
12 |
Correct |
1 ms |
2356 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2392 KB |
Output is correct |
2 |
Correct |
10 ms |
3160 KB |
Output is correct |
3 |
Correct |
117 ms |
8956 KB |
Output is correct |
4 |
Correct |
101 ms |
8924 KB |
Output is correct |
5 |
Correct |
110 ms |
8932 KB |
Output is correct |
6 |
Correct |
91 ms |
8928 KB |
Output is correct |
7 |
Correct |
110 ms |
8904 KB |
Output is correct |
8 |
Correct |
114 ms |
9100 KB |
Output is correct |
9 |
Correct |
116 ms |
8932 KB |
Output is correct |
10 |
Correct |
106 ms |
8924 KB |
Output is correct |
11 |
Correct |
102 ms |
8340 KB |
Output is correct |
12 |
Correct |
106 ms |
8344 KB |
Output is correct |
13 |
Correct |
104 ms |
8616 KB |
Output is correct |
14 |
Correct |
108 ms |
8344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
3160 KB |
Output is correct |
2 |
Correct |
18 ms |
3832 KB |
Output is correct |
3 |
Correct |
24 ms |
4424 KB |
Output is correct |
4 |
Correct |
73 ms |
8340 KB |
Output is correct |
5 |
Correct |
74 ms |
8360 KB |
Output is correct |
6 |
Correct |
71 ms |
8340 KB |
Output is correct |
7 |
Correct |
74 ms |
8612 KB |
Output is correct |
8 |
Correct |
72 ms |
8300 KB |
Output is correct |
9 |
Correct |
78 ms |
8584 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
11 ms |
3264 KB |
Output is correct |
3 |
Correct |
92 ms |
7636 KB |
Output is correct |
4 |
Correct |
142 ms |
9156 KB |
Output is correct |
5 |
Correct |
113 ms |
8924 KB |
Output is correct |
6 |
Correct |
115 ms |
8924 KB |
Output is correct |
7 |
Correct |
117 ms |
8964 KB |
Output is correct |
8 |
Correct |
118 ms |
8924 KB |
Output is correct |
9 |
Correct |
101 ms |
8928 KB |
Output is correct |
10 |
Correct |
113 ms |
8908 KB |
Output is correct |
11 |
Correct |
97 ms |
8348 KB |
Output is correct |
12 |
Correct |
107 ms |
8592 KB |
Output is correct |
13 |
Correct |
98 ms |
8348 KB |
Output is correct |
14 |
Correct |
102 ms |
8512 KB |
Output is correct |
15 |
Correct |
115 ms |
8952 KB |
Output is correct |
16 |
Correct |
112 ms |
8936 KB |
Output is correct |
17 |
Correct |
96 ms |
8408 KB |
Output is correct |
18 |
Correct |
102 ms |
8348 KB |
Output is correct |
19 |
Correct |
123 ms |
9064 KB |
Output is correct |
20 |
Correct |
102 ms |
8356 KB |
Output is correct |
21 |
Correct |
92 ms |
9444 KB |
Output is correct |
22 |
Correct |
85 ms |
9440 KB |
Output is correct |
23 |
Correct |
82 ms |
9272 KB |
Output is correct |
24 |
Correct |
80 ms |
9128 KB |
Output is correct |
25 |
Correct |
98 ms |
8676 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
3160 KB |
Output is correct |
2 |
Correct |
12 ms |
3160 KB |
Output is correct |
3 |
Correct |
124 ms |
9472 KB |
Output is correct |
4 |
Correct |
143 ms |
9748 KB |
Output is correct |
5 |
Correct |
158 ms |
11344 KB |
Output is correct |
6 |
Correct |
164 ms |
11208 KB |
Output is correct |
7 |
Correct |
151 ms |
11204 KB |
Output is correct |
8 |
Correct |
158 ms |
11192 KB |
Output is correct |
9 |
Correct |
111 ms |
8972 KB |
Output is correct |
10 |
Correct |
111 ms |
9852 KB |
Output is correct |
11 |
Correct |
110 ms |
9776 KB |
Output is correct |
12 |
Correct |
151 ms |
10828 KB |
Output is correct |
13 |
Correct |
148 ms |
11020 KB |
Output is correct |
14 |
Correct |
134 ms |
11216 KB |
Output is correct |
15 |
Correct |
145 ms |
11164 KB |
Output is correct |
16 |
Correct |
125 ms |
10240 KB |
Output is correct |
17 |
Correct |
90 ms |
9460 KB |
Output is correct |
18 |
Correct |
99 ms |
9636 KB |
Output is correct |
19 |
Correct |
108 ms |
9712 KB |
Output is correct |
20 |
Correct |
100 ms |
9636 KB |
Output is correct |
21 |
Correct |
179 ms |
10968 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
3156 KB |
Output is correct |
2 |
Correct |
11 ms |
3160 KB |
Output is correct |
3 |
Partially correct |
143 ms |
9368 KB |
Output is partially correct |
4 |
Partially correct |
134 ms |
9468 KB |
Output is partially correct |
5 |
Correct |
127 ms |
9904 KB |
Output is correct |
6 |
Partially correct |
151 ms |
11152 KB |
Output is partially correct |
7 |
Partially correct |
138 ms |
9772 KB |
Output is partially correct |
8 |
Partially correct |
130 ms |
9488 KB |
Output is partially correct |
9 |
Partially correct |
151 ms |
9744 KB |
Output is partially correct |
10 |
Partially correct |
176 ms |
11196 KB |
Output is partially correct |
11 |
Correct |
173 ms |
11200 KB |
Output is correct |
12 |
Partially correct |
167 ms |
11184 KB |
Output is partially correct |
13 |
Correct |
127 ms |
10000 KB |
Output is correct |
14 |
Correct |
108 ms |
9432 KB |
Output is correct |
15 |
Correct |
116 ms |
9792 KB |
Output is correct |
16 |
Correct |
112 ms |
9420 KB |
Output is correct |
17 |
Correct |
137 ms |
10000 KB |
Output is correct |
18 |
Correct |
107 ms |
9492 KB |
Output is correct |
19 |
Correct |
146 ms |
10828 KB |
Output is correct |
20 |
Partially correct |
169 ms |
11004 KB |
Output is partially correct |
21 |
Partially correct |
146 ms |
11436 KB |
Output is partially correct |
22 |
Correct |
157 ms |
11208 KB |
Output is correct |
23 |
Correct |
148 ms |
11628 KB |
Output is correct |
24 |
Partially correct |
164 ms |
11212 KB |
Output is partially correct |
25 |
Partially correct |
186 ms |
11208 KB |
Output is partially correct |
26 |
Partially correct |
180 ms |
11220 KB |
Output is partially correct |
27 |
Correct |
111 ms |
9580 KB |
Output is correct |
28 |
Correct |
102 ms |
9484 KB |
Output is correct |
29 |
Partially correct |
110 ms |
10136 KB |
Output is partially correct |
30 |
Partially correct |
93 ms |
9552 KB |
Output is partially correct |
31 |
Partially correct |
109 ms |
9536 KB |
Output is partially correct |
32 |
Correct |
89 ms |
9436 KB |
Output is correct |
33 |
Correct |
92 ms |
9700 KB |
Output is correct |
34 |
Correct |
97 ms |
9556 KB |
Output is correct |
35 |
Partially correct |
104 ms |
9536 KB |
Output is partially correct |
36 |
Correct |
92 ms |
9444 KB |
Output is correct |
37 |
Partially correct |
112 ms |
10140 KB |
Output is partially correct |
38 |
Correct |
95 ms |
9568 KB |
Output is correct |
39 |
Correct |
156 ms |
10872 KB |
Output is correct |
40 |
Correct |
157 ms |
10720 KB |
Output is correct |
41 |
Correct |
125 ms |
10704 KB |
Output is correct |
42 |
Correct |
186 ms |
10700 KB |
Output is correct |