#include "highway.h"
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define pb push_back
#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100005], path, w;
long long def;
int p[100005], cat[100005];
vector<int> com[3];
int solve(vector<int>& ve){
reverse(ve.begin(), ve.end());
int l = 0, r = ve.size() - 1;
while(l != r){
int m = (l + r) >> 1;
FOR(i, 0, m)
w[p[ve[i]]] = 1;
if(ask(w) > def) r = m;
else l = m + 1;
for(int i = 0; i <= m; i++)
w[p[ve[i]]] = 0;
}
return ve[l];
}
void find_pair(int N, vector<int> U, vector<int> V, int A, int B) {
int m = U.size();
FOR(i, 0, m - 1){
adj[U[i]].pb(i);
adj[V[i]].pb(i);
path.push_back(V[i] + U[i]);
}
w = vector<int>(m, 0);
def = ask(w);
int l = 0, r = m - 1;
while(l != r){
int mm = (l + r) >> 1;
FOR(i, 0, mm)
w[i] = 1;
if(ask(w) > def) r = mm;
else l = mm + 1;
FOR(i, 0, mm)
w[i] = 0;
}
queue<pair<int, int> > q;
q.push({V[l], 1});
q.push({U[l], 2});
cat[V[l]] = 1;
p[V[l]] = l;
p[U[l]] = l;
cat[U[l]] = 2;
com[1].push_back(V[l]);
com[2].push_back(U[l]);
while(!q.empty()){
int u = q.front().first, t = q.front().second;
q.pop();
for(int x : adj[u]){
int e = path[x] - u;
if(cat[e]) continue;
cat[e] = t;
com[t].push_back(e);
p[e] = x;
q.push({e, t});
}
}
FOR(i, 0, m - 1)
w[i] = 1;
FOR(i, 0, N - 1)
w[p[i]] = 0;
answer(solve(com[1]), solve(com[2]));
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
2608 KB |
Output is correct |
2 |
Correct |
4 ms |
2552 KB |
Output is correct |
3 |
Correct |
4 ms |
2680 KB |
Output is correct |
4 |
Correct |
4 ms |
2672 KB |
Output is correct |
5 |
Correct |
5 ms |
2712 KB |
Output is correct |
6 |
Correct |
4 ms |
2676 KB |
Output is correct |
7 |
Correct |
4 ms |
2728 KB |
Output is correct |
8 |
Correct |
4 ms |
2680 KB |
Output is correct |
9 |
Correct |
4 ms |
2556 KB |
Output is correct |
10 |
Correct |
4 ms |
2552 KB |
Output is correct |
11 |
Correct |
4 ms |
2680 KB |
Output is correct |
12 |
Correct |
4 ms |
2672 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
2684 KB |
Output is correct |
2 |
Correct |
27 ms |
3384 KB |
Output is correct |
3 |
Correct |
212 ms |
9124 KB |
Output is correct |
4 |
Correct |
226 ms |
9132 KB |
Output is correct |
5 |
Correct |
238 ms |
9144 KB |
Output is correct |
6 |
Correct |
189 ms |
9132 KB |
Output is correct |
7 |
Correct |
231 ms |
9128 KB |
Output is correct |
8 |
Correct |
262 ms |
9132 KB |
Output is correct |
9 |
Correct |
271 ms |
9124 KB |
Output is correct |
10 |
Correct |
223 ms |
9128 KB |
Output is correct |
11 |
Correct |
271 ms |
8992 KB |
Output is correct |
12 |
Correct |
258 ms |
9160 KB |
Output is correct |
13 |
Correct |
253 ms |
9024 KB |
Output is correct |
14 |
Correct |
257 ms |
9028 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
3300 KB |
Output is correct |
2 |
Correct |
40 ms |
4096 KB |
Output is correct |
3 |
Correct |
63 ms |
4816 KB |
Output is correct |
4 |
Correct |
158 ms |
8976 KB |
Output is correct |
5 |
Correct |
187 ms |
8980 KB |
Output is correct |
6 |
Correct |
160 ms |
9364 KB |
Output is correct |
7 |
Correct |
210 ms |
8900 KB |
Output is correct |
8 |
Correct |
172 ms |
8984 KB |
Output is correct |
9 |
Correct |
201 ms |
9264 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
2680 KB |
Output is correct |
2 |
Correct |
34 ms |
3356 KB |
Output is correct |
3 |
Correct |
196 ms |
7900 KB |
Output is correct |
4 |
Correct |
249 ms |
9132 KB |
Output is correct |
5 |
Correct |
232 ms |
9160 KB |
Output is correct |
6 |
Correct |
243 ms |
9128 KB |
Output is correct |
7 |
Correct |
252 ms |
9120 KB |
Output is correct |
8 |
Correct |
246 ms |
9180 KB |
Output is correct |
9 |
Correct |
235 ms |
9144 KB |
Output is correct |
10 |
Correct |
258 ms |
9124 KB |
Output is correct |
11 |
Correct |
251 ms |
9024 KB |
Output is correct |
12 |
Correct |
236 ms |
9284 KB |
Output is correct |
13 |
Correct |
257 ms |
9268 KB |
Output is correct |
14 |
Correct |
276 ms |
9012 KB |
Output is correct |
15 |
Correct |
263 ms |
9112 KB |
Output is correct |
16 |
Correct |
264 ms |
9180 KB |
Output is correct |
17 |
Correct |
281 ms |
9108 KB |
Output is correct |
18 |
Correct |
263 ms |
9104 KB |
Output is correct |
19 |
Correct |
234 ms |
9180 KB |
Output is correct |
20 |
Correct |
237 ms |
8992 KB |
Output is correct |
21 |
Correct |
197 ms |
9864 KB |
Output is correct |
22 |
Correct |
193 ms |
9964 KB |
Output is correct |
23 |
Correct |
201 ms |
9472 KB |
Output is correct |
24 |
Correct |
194 ms |
9396 KB |
Output is correct |
25 |
Correct |
213 ms |
9212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
48 ms |
3460 KB |
Output is correct |
2 |
Correct |
31 ms |
3476 KB |
Output is correct |
3 |
Correct |
256 ms |
9568 KB |
Output is correct |
4 |
Correct |
305 ms |
9736 KB |
Output is correct |
5 |
Correct |
357 ms |
10448 KB |
Output is correct |
6 |
Correct |
349 ms |
10576 KB |
Output is correct |
7 |
Correct |
351 ms |
10460 KB |
Output is correct |
8 |
Correct |
328 ms |
10348 KB |
Output is correct |
9 |
Correct |
236 ms |
7988 KB |
Output is correct |
10 |
Correct |
271 ms |
8336 KB |
Output is correct |
11 |
Correct |
267 ms |
8636 KB |
Output is correct |
12 |
Correct |
285 ms |
9800 KB |
Output is correct |
13 |
Correct |
350 ms |
10044 KB |
Output is correct |
14 |
Correct |
334 ms |
10052 KB |
Output is correct |
15 |
Correct |
337 ms |
10120 KB |
Output is correct |
16 |
Correct |
261 ms |
8800 KB |
Output is correct |
17 |
Correct |
221 ms |
10032 KB |
Output is correct |
18 |
Correct |
225 ms |
10080 KB |
Output is correct |
19 |
Correct |
199 ms |
9944 KB |
Output is correct |
20 |
Correct |
238 ms |
10036 KB |
Output is correct |
21 |
Correct |
322 ms |
10436 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
3448 KB |
Output is correct |
2 |
Correct |
32 ms |
3368 KB |
Output is correct |
3 |
Correct |
285 ms |
9468 KB |
Output is correct |
4 |
Correct |
294 ms |
9856 KB |
Output is correct |
5 |
Correct |
305 ms |
9876 KB |
Output is correct |
6 |
Correct |
356 ms |
10448 KB |
Output is correct |
7 |
Correct |
245 ms |
9548 KB |
Output is correct |
8 |
Correct |
301 ms |
9812 KB |
Output is correct |
9 |
Correct |
322 ms |
9952 KB |
Output is correct |
10 |
Correct |
359 ms |
10596 KB |
Output is correct |
11 |
Correct |
354 ms |
10568 KB |
Output is correct |
12 |
Correct |
346 ms |
10468 KB |
Output is correct |
13 |
Correct |
270 ms |
8544 KB |
Output is correct |
14 |
Correct |
262 ms |
8288 KB |
Output is correct |
15 |
Correct |
248 ms |
8564 KB |
Output is correct |
16 |
Correct |
239 ms |
8392 KB |
Output is correct |
17 |
Correct |
237 ms |
8640 KB |
Output is correct |
18 |
Correct |
217 ms |
8296 KB |
Output is correct |
19 |
Correct |
350 ms |
9740 KB |
Output is correct |
20 |
Correct |
337 ms |
10008 KB |
Output is correct |
21 |
Correct |
352 ms |
10080 KB |
Output is correct |
22 |
Correct |
314 ms |
10176 KB |
Output is correct |
23 |
Correct |
359 ms |
10380 KB |
Output is correct |
24 |
Correct |
332 ms |
10172 KB |
Output is correct |
25 |
Correct |
347 ms |
10316 KB |
Output is correct |
26 |
Correct |
358 ms |
10316 KB |
Output is correct |
27 |
Correct |
223 ms |
9996 KB |
Output is correct |
28 |
Correct |
232 ms |
10080 KB |
Output is correct |
29 |
Correct |
239 ms |
10140 KB |
Output is correct |
30 |
Correct |
195 ms |
9916 KB |
Output is correct |
31 |
Correct |
226 ms |
9964 KB |
Output is correct |
32 |
Correct |
210 ms |
9900 KB |
Output is correct |
33 |
Correct |
213 ms |
10100 KB |
Output is correct |
34 |
Correct |
222 ms |
9992 KB |
Output is correct |
35 |
Correct |
239 ms |
10008 KB |
Output is correct |
36 |
Correct |
249 ms |
9868 KB |
Output is correct |
37 |
Correct |
222 ms |
10220 KB |
Output is correct |
38 |
Correct |
195 ms |
9932 KB |
Output is correct |
39 |
Correct |
342 ms |
10344 KB |
Output is correct |
40 |
Correct |
326 ms |
10312 KB |
Output is correct |
41 |
Correct |
298 ms |
10208 KB |
Output is correct |
42 |
Correct |
373 ms |
10168 KB |
Output is correct |