#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define pb push_back
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rrep(i,n) for(int i=1; i<=(n); ++i)
#define printf if(0) printf
ll ask(const vector<int>&);
void answer(int, int);
vector<int> asking;
int n, m;
vector<int> e[90010];
int es[130010];
ll base;
bool dead[90010];
int find_cut(){
int l=-1, r=n-1;
while(l+1<r){
int mid=(l+r)/2;
printf("asking sum %d->", accumulate(asking.begin(), asking.end(), 0));
for(int i=l+1; i<=mid; ++i){
for(int ei:e[i]) asking[ei]=1;
}
printf("%d, ", accumulate(asking.begin(), asking.end(), 0));
printf("trying to block %d-%d\n", l+1, mid);
bool res = (ask(asking) > base);
if(res){
printf("increase!\n");
for(int i=l+1; i<=mid; ++i){
for(int ei:e[i]){
int j=es[ei]-i;
if(!dead[j]) asking[ei]=0;
}
}
r = mid;
} else {
printf("no diff... killing all");
for(int i=l+1; i<=mid; ++i) dead[i]=1;
l = mid;
}
}
return r;
}
int cut;
int dst[90010];
int q[90010], hd, tl;
bool vis[90010];
int find_deep(int l, int r){
if(l == r){
return q[l];
}
int mid=(l+r)/2;
for(int i=mid+1; i<=r; ++i) for(int ei:e[q[i]]) asking[ei]=1;
bool res = (ask(asking) > base);
for(int i=mid+1; i<=r; ++i) for(int ei:e[q[i]]){
int j=es[ei]-q[i];
if(!dead[j]) asking[ei]=0;
}
if(res) return find_deep(mid+1, r);
else return find_deep(l, mid);
}
void muko(int z){
queue<int> q;
q.push(z);
dead[z]=1;
printf("kill %d", z);
for(;q.size();){
int x = q.front(); q.pop();
for(int ei:e[x]){
int y=es[ei]-x;
if(dst[y]==dst[x]-1 && !dead[y]){
dead[y]=1;
printf(", %d", y);
q.push(y);
}
}
}
putchar(10);
}
void find_pair(int N, vector<int> U, vector<int> V, int A, int B) {
// find cut vertex
n = N;
m = U.size();
asking.resize(m);
base = ask(asking);
printf("base %lld\n", base);
for(int i=0; i<m; ++i){
int a = U[i], b = V[i];
e[a].pb(i); e[b].pb(i);
es[i]=a+b;
}
cut = find_cut();
printf("cut %d\n", cut);
q[hd++] = cut;
vis[cut]=1;
while(hd>tl){
int x=q[tl++];
for(int ei:e[x]){
int y=es[ei]-x;
if(dead[y]) continue;
if(!vis[y]){
vis[y]=1;
dst[y]=dst[x]+1;
q[hd++]=y;
}
}
}
int deep = find_deep(0, hd-1);
//printf("deep %d\n", deep);
muko(deep);
dead[cut]=0;
vector<int> tmp;
int tg = base / A - dst[deep];
rep(i, n){
if(dead[i]) continue;
if(dst[i] == tg) tmp.pb(i);
}
int s = tmp.size();
rep(i, s) q[i] = tmp[i];
int d2 = find_deep(0, s-1);
printf("d2 %d\n", d2);
answer(deep, d2);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
2424 KB |
Output is correct |
2 |
Correct |
3 ms |
2452 KB |
Output is correct |
3 |
Correct |
4 ms |
2544 KB |
Output is correct |
4 |
Correct |
4 ms |
2424 KB |
Output is correct |
5 |
Correct |
4 ms |
2424 KB |
Output is correct |
6 |
Correct |
4 ms |
2424 KB |
Output is correct |
7 |
Correct |
4 ms |
2424 KB |
Output is correct |
8 |
Correct |
4 ms |
2524 KB |
Output is correct |
9 |
Correct |
4 ms |
2424 KB |
Output is correct |
10 |
Correct |
4 ms |
2424 KB |
Output is correct |
11 |
Correct |
4 ms |
2432 KB |
Output is correct |
12 |
Correct |
4 ms |
2444 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
2424 KB |
Output is correct |
2 |
Correct |
22 ms |
3124 KB |
Output is correct |
3 |
Correct |
232 ms |
8276 KB |
Output is correct |
4 |
Correct |
244 ms |
8284 KB |
Output is correct |
5 |
Correct |
215 ms |
8372 KB |
Output is correct |
6 |
Correct |
221 ms |
8360 KB |
Output is correct |
7 |
Correct |
204 ms |
8356 KB |
Output is correct |
8 |
Correct |
242 ms |
8272 KB |
Output is correct |
9 |
Correct |
222 ms |
8280 KB |
Output is correct |
10 |
Correct |
242 ms |
8284 KB |
Output is correct |
11 |
Correct |
239 ms |
8176 KB |
Output is correct |
12 |
Correct |
261 ms |
8176 KB |
Output is correct |
13 |
Correct |
279 ms |
8176 KB |
Output is correct |
14 |
Correct |
234 ms |
8180 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
3064 KB |
Output is correct |
2 |
Correct |
39 ms |
3604 KB |
Output is correct |
3 |
Correct |
56 ms |
4164 KB |
Output is correct |
4 |
Correct |
163 ms |
7920 KB |
Output is correct |
5 |
Correct |
166 ms |
7932 KB |
Output is correct |
6 |
Correct |
177 ms |
8056 KB |
Output is correct |
7 |
Correct |
167 ms |
7620 KB |
Output is correct |
8 |
Correct |
145 ms |
7976 KB |
Output is correct |
9 |
Correct |
138 ms |
7656 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
2424 KB |
Output is correct |
2 |
Correct |
27 ms |
3064 KB |
Output is correct |
3 |
Correct |
161 ms |
6876 KB |
Output is correct |
4 |
Correct |
199 ms |
8016 KB |
Output is correct |
5 |
Correct |
226 ms |
8172 KB |
Output is correct |
6 |
Correct |
194 ms |
7912 KB |
Output is correct |
7 |
Correct |
226 ms |
8440 KB |
Output is correct |
8 |
Correct |
241 ms |
8024 KB |
Output is correct |
9 |
Correct |
235 ms |
8264 KB |
Output is correct |
10 |
Correct |
203 ms |
8340 KB |
Output is correct |
11 |
Correct |
208 ms |
7924 KB |
Output is correct |
12 |
Correct |
214 ms |
8136 KB |
Output is correct |
13 |
Correct |
246 ms |
8100 KB |
Output is correct |
14 |
Correct |
212 ms |
8084 KB |
Output is correct |
15 |
Correct |
198 ms |
8192 KB |
Output is correct |
16 |
Correct |
191 ms |
7964 KB |
Output is correct |
17 |
Correct |
236 ms |
8072 KB |
Output is correct |
18 |
Correct |
213 ms |
7908 KB |
Output is correct |
19 |
Correct |
220 ms |
8508 KB |
Output is correct |
20 |
Correct |
180 ms |
7860 KB |
Output is correct |
21 |
Correct |
214 ms |
8868 KB |
Output is correct |
22 |
Correct |
200 ms |
8180 KB |
Output is correct |
23 |
Correct |
196 ms |
9048 KB |
Output is correct |
24 |
Correct |
216 ms |
8952 KB |
Output is correct |
25 |
Correct |
295 ms |
8368 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
31 ms |
3136 KB |
Output is correct |
2 |
Correct |
27 ms |
3196 KB |
Output is correct |
3 |
Correct |
269 ms |
8580 KB |
Output is correct |
4 |
Correct |
292 ms |
8744 KB |
Output is correct |
5 |
Correct |
325 ms |
9372 KB |
Output is correct |
6 |
Correct |
371 ms |
9340 KB |
Output is correct |
7 |
Correct |
295 ms |
9356 KB |
Output is correct |
8 |
Correct |
348 ms |
9380 KB |
Output is correct |
9 |
Correct |
260 ms |
7452 KB |
Output is correct |
10 |
Correct |
256 ms |
7676 KB |
Output is correct |
11 |
Correct |
247 ms |
7556 KB |
Output is correct |
12 |
Correct |
291 ms |
8880 KB |
Output is correct |
13 |
Correct |
325 ms |
9168 KB |
Output is correct |
14 |
Correct |
327 ms |
9264 KB |
Output is correct |
15 |
Correct |
312 ms |
9252 KB |
Output is correct |
16 |
Correct |
280 ms |
8200 KB |
Output is correct |
17 |
Correct |
224 ms |
8688 KB |
Output is correct |
18 |
Correct |
216 ms |
8688 KB |
Output is correct |
19 |
Correct |
201 ms |
8724 KB |
Output is correct |
20 |
Correct |
227 ms |
8648 KB |
Output is correct |
21 |
Correct |
305 ms |
9424 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
3148 KB |
Output is correct |
2 |
Correct |
32 ms |
3256 KB |
Output is correct |
3 |
Correct |
254 ms |
8600 KB |
Output is correct |
4 |
Correct |
270 ms |
8752 KB |
Output is correct |
5 |
Correct |
281 ms |
8724 KB |
Output is correct |
6 |
Correct |
308 ms |
9412 KB |
Output is correct |
7 |
Correct |
257 ms |
8536 KB |
Output is correct |
8 |
Correct |
287 ms |
8704 KB |
Output is correct |
9 |
Correct |
263 ms |
8876 KB |
Output is correct |
10 |
Correct |
349 ms |
9404 KB |
Output is correct |
11 |
Correct |
341 ms |
9336 KB |
Output is correct |
12 |
Correct |
301 ms |
9412 KB |
Output is correct |
13 |
Correct |
271 ms |
7620 KB |
Output is correct |
14 |
Correct |
248 ms |
7852 KB |
Output is correct |
15 |
Correct |
263 ms |
7764 KB |
Output is correct |
16 |
Correct |
263 ms |
7736 KB |
Output is correct |
17 |
Correct |
246 ms |
7512 KB |
Output is correct |
18 |
Correct |
227 ms |
7760 KB |
Output is correct |
19 |
Correct |
285 ms |
8844 KB |
Output is correct |
20 |
Correct |
295 ms |
9116 KB |
Output is correct |
21 |
Correct |
366 ms |
9208 KB |
Output is correct |
22 |
Correct |
313 ms |
9140 KB |
Output is correct |
23 |
Correct |
302 ms |
9276 KB |
Output is correct |
24 |
Correct |
314 ms |
9344 KB |
Output is correct |
25 |
Correct |
300 ms |
9032 KB |
Output is correct |
26 |
Correct |
303 ms |
9248 KB |
Output is correct |
27 |
Correct |
218 ms |
8656 KB |
Output is correct |
28 |
Correct |
238 ms |
8800 KB |
Output is correct |
29 |
Correct |
221 ms |
8684 KB |
Output is correct |
30 |
Correct |
181 ms |
8504 KB |
Output is correct |
31 |
Correct |
223 ms |
8680 KB |
Output is correct |
32 |
Correct |
195 ms |
8588 KB |
Output is correct |
33 |
Correct |
213 ms |
8760 KB |
Output is correct |
34 |
Correct |
215 ms |
8708 KB |
Output is correct |
35 |
Correct |
215 ms |
8736 KB |
Output is correct |
36 |
Correct |
218 ms |
8640 KB |
Output is correct |
37 |
Correct |
224 ms |
8768 KB |
Output is correct |
38 |
Correct |
229 ms |
8560 KB |
Output is correct |
39 |
Correct |
296 ms |
9432 KB |
Output is correct |
40 |
Correct |
286 ms |
9324 KB |
Output is correct |
41 |
Correct |
291 ms |
9424 KB |
Output is correct |
42 |
Correct |
274 ms |
9388 KB |
Output is correct |