#include "highway.h"
#include <bits/stdc++.h>
#define mp make_pair
#define f first
#define s second
#define sz(x) (int)(x).size()
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
template<class T>bool tmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool tmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
ll k;
vpl con[100000];
vi u,v,w,tree[2];
bool vis[100000],fin[100000];
int func(vector<int> &tree)
{
int l=0;int r=sz(tree)-1;
while(l<r)
{
int mid=(l+r)/2;
for (int i=mid+1;i<=r;i++) fin[tree[i]]=1;
for (int i=0;i<sz(u);i++)
{
if (fin[u[i]]!=fin[v[i]])
{
w[i]=1;
}
}
if (k!=ask(w)) l=mid+1;
else r=mid;
for (int i=0;i<sz(u);i++) w[i]=0;
for (int i=mid+1;i<=r;i++) fin[tree[i]]=0;
}
return tree[l];
}
void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B)
{
u=U;v=V;
for (int i=0;i<sz(U);i++)
{
con[U[i]].pb({V[i],i});
con[V[i]].pb({U[i],i});
}
w.resize(sz(U));
k=ask(w);
int l=0;int r=sz(U)-1;
while(l<r)
{
int mid=(l+r)/2;
for (int i=l;i<=mid;i++) w[i]=1;
if (k!=ask(w)) r=mid;
else l=mid+1;
for (int i=l;i<=mid;i++) w[i]=0;
}
queue<pl> q;
q.push({0,U[l]});
q.push({1,V[l]});
vis[U[l]]=vis[V[l]]=1;
while(sz(q))
{
int bar=q.front().f;
int la=q.front().s;
q.pop();
tree[bar].pb(la);
for (auto i:con[la])
{
if (!vis[i.f])
{
vis[i.f]=1;
q.push({bar,i.f});
}
}
}
answer(func(tree[0]),func(tree[1]));
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2688 KB |
Output is correct |
2 |
Correct |
2 ms |
2688 KB |
Output is correct |
3 |
Correct |
2 ms |
2688 KB |
Output is correct |
4 |
Correct |
2 ms |
2688 KB |
Output is correct |
5 |
Correct |
2 ms |
2688 KB |
Output is correct |
6 |
Correct |
2 ms |
2688 KB |
Output is correct |
7 |
Correct |
2 ms |
2688 KB |
Output is correct |
8 |
Correct |
2 ms |
2688 KB |
Output is correct |
9 |
Correct |
2 ms |
2688 KB |
Output is correct |
10 |
Correct |
2 ms |
2688 KB |
Output is correct |
11 |
Correct |
2 ms |
2688 KB |
Output is correct |
12 |
Correct |
2 ms |
2688 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2816 KB |
Output is correct |
2 |
Correct |
15 ms |
3556 KB |
Output is correct |
3 |
Correct |
148 ms |
10708 KB |
Output is correct |
4 |
Correct |
149 ms |
10720 KB |
Output is correct |
5 |
Correct |
157 ms |
10800 KB |
Output is correct |
6 |
Correct |
140 ms |
10692 KB |
Output is correct |
7 |
Correct |
152 ms |
10600 KB |
Output is correct |
8 |
Correct |
150 ms |
10620 KB |
Output is correct |
9 |
Correct |
143 ms |
10600 KB |
Output is correct |
10 |
Correct |
154 ms |
10600 KB |
Output is correct |
11 |
Correct |
149 ms |
10476 KB |
Output is correct |
12 |
Correct |
163 ms |
10604 KB |
Output is correct |
13 |
Correct |
157 ms |
10632 KB |
Output is correct |
14 |
Correct |
158 ms |
10576 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
3584 KB |
Output is correct |
2 |
Correct |
27 ms |
4344 KB |
Output is correct |
3 |
Correct |
40 ms |
5308 KB |
Output is correct |
4 |
Correct |
123 ms |
10100 KB |
Output is correct |
5 |
Correct |
125 ms |
10232 KB |
Output is correct |
6 |
Correct |
121 ms |
10116 KB |
Output is correct |
7 |
Correct |
124 ms |
10052 KB |
Output is correct |
8 |
Correct |
120 ms |
10072 KB |
Output is correct |
9 |
Correct |
125 ms |
10244 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2816 KB |
Output is correct |
2 |
Correct |
32 ms |
3604 KB |
Output is correct |
3 |
Correct |
102 ms |
9004 KB |
Output is correct |
4 |
Correct |
144 ms |
10600 KB |
Output is correct |
5 |
Correct |
145 ms |
10592 KB |
Output is correct |
6 |
Correct |
137 ms |
10600 KB |
Output is correct |
7 |
Correct |
139 ms |
10600 KB |
Output is correct |
8 |
Correct |
150 ms |
10596 KB |
Output is correct |
9 |
Correct |
160 ms |
10600 KB |
Output is correct |
10 |
Correct |
142 ms |
10596 KB |
Output is correct |
11 |
Correct |
165 ms |
10620 KB |
Output is correct |
12 |
Correct |
190 ms |
10708 KB |
Output is correct |
13 |
Correct |
170 ms |
10776 KB |
Output is correct |
14 |
Correct |
151 ms |
10512 KB |
Output is correct |
15 |
Correct |
146 ms |
10588 KB |
Output is correct |
16 |
Correct |
186 ms |
10612 KB |
Output is correct |
17 |
Correct |
157 ms |
10812 KB |
Output is correct |
18 |
Correct |
166 ms |
10664 KB |
Output is correct |
19 |
Correct |
137 ms |
10708 KB |
Output is correct |
20 |
Correct |
163 ms |
10788 KB |
Output is correct |
21 |
Correct |
160 ms |
11236 KB |
Output is correct |
22 |
Correct |
120 ms |
11236 KB |
Output is correct |
23 |
Correct |
182 ms |
10844 KB |
Output is correct |
24 |
Correct |
139 ms |
10764 KB |
Output is correct |
25 |
Correct |
165 ms |
10772 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
3712 KB |
Output is correct |
2 |
Correct |
19 ms |
3712 KB |
Output is correct |
3 |
Correct |
168 ms |
11620 KB |
Output is correct |
4 |
Correct |
192 ms |
12736 KB |
Output is correct |
5 |
Correct |
248 ms |
14324 KB |
Output is correct |
6 |
Correct |
244 ms |
14232 KB |
Output is correct |
7 |
Correct |
227 ms |
14168 KB |
Output is correct |
8 |
Correct |
238 ms |
14204 KB |
Output is correct |
9 |
Correct |
165 ms |
12068 KB |
Output is correct |
10 |
Correct |
181 ms |
13100 KB |
Output is correct |
11 |
Correct |
203 ms |
13264 KB |
Output is correct |
12 |
Correct |
231 ms |
14064 KB |
Output is correct |
13 |
Correct |
239 ms |
14236 KB |
Output is correct |
14 |
Correct |
235 ms |
14136 KB |
Output is correct |
15 |
Correct |
227 ms |
14040 KB |
Output is correct |
16 |
Correct |
222 ms |
13668 KB |
Output is correct |
17 |
Correct |
194 ms |
11708 KB |
Output is correct |
18 |
Correct |
220 ms |
11828 KB |
Output is correct |
19 |
Correct |
143 ms |
11728 KB |
Output is correct |
20 |
Correct |
150 ms |
11664 KB |
Output is correct |
21 |
Correct |
285 ms |
13916 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
3584 KB |
Output is correct |
2 |
Correct |
24 ms |
3864 KB |
Output is correct |
3 |
Correct |
229 ms |
11664 KB |
Output is correct |
4 |
Correct |
177 ms |
12124 KB |
Output is correct |
5 |
Correct |
196 ms |
12616 KB |
Output is correct |
6 |
Correct |
296 ms |
14360 KB |
Output is correct |
7 |
Correct |
165 ms |
11844 KB |
Output is correct |
8 |
Correct |
179 ms |
12044 KB |
Output is correct |
9 |
Correct |
223 ms |
12572 KB |
Output is correct |
10 |
Correct |
243 ms |
14184 KB |
Output is correct |
11 |
Correct |
224 ms |
14104 KB |
Output is correct |
12 |
Correct |
224 ms |
14484 KB |
Output is correct |
13 |
Correct |
234 ms |
13184 KB |
Output is correct |
14 |
Correct |
175 ms |
13100 KB |
Output is correct |
15 |
Correct |
210 ms |
13192 KB |
Output is correct |
16 |
Correct |
194 ms |
13116 KB |
Output is correct |
17 |
Correct |
210 ms |
13088 KB |
Output is correct |
18 |
Correct |
256 ms |
13092 KB |
Output is correct |
19 |
Correct |
277 ms |
14080 KB |
Output is correct |
20 |
Correct |
212 ms |
14296 KB |
Output is correct |
21 |
Correct |
230 ms |
14240 KB |
Output is correct |
22 |
Correct |
242 ms |
14220 KB |
Output is correct |
23 |
Correct |
263 ms |
14076 KB |
Output is correct |
24 |
Correct |
240 ms |
14144 KB |
Output is correct |
25 |
Correct |
269 ms |
14232 KB |
Output is correct |
26 |
Correct |
302 ms |
14176 KB |
Output is correct |
27 |
Correct |
146 ms |
11584 KB |
Output is correct |
28 |
Correct |
141 ms |
11320 KB |
Output is correct |
29 |
Correct |
166 ms |
12088 KB |
Output is correct |
30 |
Correct |
138 ms |
11408 KB |
Output is correct |
31 |
Correct |
157 ms |
11436 KB |
Output is correct |
32 |
Correct |
163 ms |
11588 KB |
Output is correct |
33 |
Correct |
167 ms |
11920 KB |
Output is correct |
34 |
Correct |
142 ms |
11440 KB |
Output is correct |
35 |
Correct |
142 ms |
11452 KB |
Output is correct |
36 |
Correct |
130 ms |
11540 KB |
Output is correct |
37 |
Correct |
145 ms |
11684 KB |
Output is correct |
38 |
Correct |
191 ms |
11820 KB |
Output is correct |
39 |
Correct |
277 ms |
13980 KB |
Output is correct |
40 |
Correct |
284 ms |
13912 KB |
Output is correct |
41 |
Correct |
294 ms |
13924 KB |
Output is correct |
42 |
Correct |
293 ms |
13800 KB |
Output is correct |