#include "insects.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn=2010;
int n;
int tren[maxn];
int perm[maxn];
int klk[maxn];
int unutra=0;
int korak=1;
int raz;
bool nemoj[maxn];
bool stabrekojikurac[maxn];
void ubaci(int i){
if(tren[i]!=0) return;
tren[i]=korak;
move_inside(perm[i]);
unutra++;
}
void izbaci(int i){
if(tren[i]==0) return;
tren[i]=0;
move_outside(perm[i]);
unutra--;
}
int pitaj(){
return press_button();
}
int nadji(){
for(int i=0;i<n;i++){
ubaci(i);
if(pitaj()>1){
izbaci(i);
}
}
return unutra;
}
mt19937 rng(23479);
bool probaj(int gran,int sled){ // da li je >=
korak++;
for(int i=0;i<n;i++){
if(unutra==raz*gran) {
for(int i=0;i<n;i++) stabrekojikurac[i]=false;
return true;
}
if(tren[i]!=0) continue;
if(nemoj[i]) continue;
ubaci(i);
if((klk[i]=pitaj())>gran){
izbaci(i);
stabrekojikurac[i]=true;
}
}
if(unutra==raz*gran) {
for(int i=0;i<n;i++) stabrekojikurac[i]=false;
return true;
}
for(int i=0;i<n;i++) if(stabrekojikurac[i]) {nemoj[i]=true; stabrekojikurac[i]=false;}
for(int i=0;i<n;i++) if(tren[i]==korak && klk[i]>1) izbaci(i);
//korak--;
return false;
}
int min_cardinality(int _n){
n=_n;
for(int i=0;i<n;i++) perm[i]=i;
shuffle(perm,perm+n,rng);
raz=nadji();
int l=1,r=n/raz;
int res=-1;
while(l<=r){
int mid=l+(r-l)/2;
int sled=l+(mid-1-l)/2;
if(probaj(mid,sled)){
res=mid;
l=mid+1;
}else r=mid-1;
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
4 ms |
208 KB |
Output is correct |
7 |
Correct |
2 ms |
208 KB |
Output is correct |
8 |
Correct |
5 ms |
208 KB |
Output is correct |
9 |
Correct |
3 ms |
208 KB |
Output is correct |
10 |
Correct |
4 ms |
208 KB |
Output is correct |
11 |
Correct |
2 ms |
208 KB |
Output is correct |
12 |
Correct |
5 ms |
208 KB |
Output is correct |
13 |
Correct |
6 ms |
208 KB |
Output is correct |
14 |
Correct |
5 ms |
208 KB |
Output is correct |
15 |
Correct |
3 ms |
208 KB |
Output is correct |
16 |
Correct |
2 ms |
208 KB |
Output is correct |
17 |
Correct |
5 ms |
208 KB |
Output is correct |
18 |
Correct |
3 ms |
208 KB |
Output is correct |
19 |
Correct |
4 ms |
208 KB |
Output is correct |
20 |
Correct |
4 ms |
208 KB |
Output is correct |
21 |
Correct |
2 ms |
208 KB |
Output is correct |
22 |
Correct |
2 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
4 ms |
208 KB |
Output is correct |
7 |
Correct |
2 ms |
208 KB |
Output is correct |
8 |
Correct |
5 ms |
208 KB |
Output is correct |
9 |
Correct |
3 ms |
208 KB |
Output is correct |
10 |
Correct |
4 ms |
208 KB |
Output is correct |
11 |
Correct |
2 ms |
208 KB |
Output is correct |
12 |
Correct |
5 ms |
208 KB |
Output is correct |
13 |
Correct |
6 ms |
208 KB |
Output is correct |
14 |
Correct |
5 ms |
208 KB |
Output is correct |
15 |
Correct |
3 ms |
208 KB |
Output is correct |
16 |
Correct |
2 ms |
208 KB |
Output is correct |
17 |
Correct |
5 ms |
208 KB |
Output is correct |
18 |
Correct |
3 ms |
208 KB |
Output is correct |
19 |
Correct |
4 ms |
208 KB |
Output is correct |
20 |
Correct |
4 ms |
208 KB |
Output is correct |
21 |
Correct |
2 ms |
208 KB |
Output is correct |
22 |
Correct |
2 ms |
208 KB |
Output is correct |
23 |
Correct |
14 ms |
208 KB |
Output is correct |
24 |
Correct |
6 ms |
328 KB |
Output is correct |
25 |
Correct |
23 ms |
324 KB |
Output is correct |
26 |
Correct |
21 ms |
320 KB |
Output is correct |
27 |
Correct |
22 ms |
308 KB |
Output is correct |
28 |
Correct |
7 ms |
328 KB |
Output is correct |
29 |
Correct |
28 ms |
208 KB |
Output is correct |
30 |
Correct |
24 ms |
324 KB |
Output is correct |
31 |
Correct |
18 ms |
328 KB |
Output is correct |
32 |
Correct |
10 ms |
208 KB |
Output is correct |
33 |
Correct |
22 ms |
208 KB |
Output is correct |
34 |
Correct |
21 ms |
316 KB |
Output is correct |
35 |
Correct |
14 ms |
208 KB |
Output is correct |
36 |
Correct |
23 ms |
324 KB |
Output is correct |
37 |
Correct |
20 ms |
208 KB |
Output is correct |
38 |
Correct |
25 ms |
324 KB |
Output is correct |
39 |
Correct |
18 ms |
208 KB |
Output is correct |
40 |
Correct |
10 ms |
208 KB |
Output is correct |
41 |
Correct |
9 ms |
324 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
42 ms |
300 KB |
Output is correct |
8 |
Correct |
10 ms |
328 KB |
Output is correct |
9 |
Correct |
32 ms |
348 KB |
Output is correct |
10 |
Correct |
30 ms |
208 KB |
Output is correct |
11 |
Correct |
31 ms |
324 KB |
Output is correct |
12 |
Correct |
18 ms |
208 KB |
Output is correct |
13 |
Correct |
52 ms |
312 KB |
Output is correct |
14 |
Correct |
36 ms |
308 KB |
Output is correct |
15 |
Correct |
29 ms |
324 KB |
Output is correct |
16 |
Correct |
24 ms |
324 KB |
Output is correct |
17 |
Correct |
30 ms |
304 KB |
Output is correct |
18 |
Correct |
42 ms |
312 KB |
Output is correct |
19 |
Correct |
33 ms |
304 KB |
Output is correct |
20 |
Correct |
33 ms |
208 KB |
Output is correct |
21 |
Correct |
37 ms |
324 KB |
Output is correct |
22 |
Correct |
47 ms |
312 KB |
Output is correct |
23 |
Correct |
50 ms |
324 KB |
Output is correct |
24 |
Correct |
20 ms |
208 KB |
Output is correct |
25 |
Correct |
26 ms |
208 KB |
Output is correct |
26 |
Correct |
8 ms |
284 KB |
Output is correct |
27 |
Correct |
29 ms |
328 KB |
Output is correct |
28 |
Correct |
43 ms |
324 KB |
Output is correct |
29 |
Correct |
32 ms |
208 KB |
Output is correct |
30 |
Correct |
21 ms |
324 KB |
Output is correct |
31 |
Correct |
37 ms |
324 KB |
Output is correct |
32 |
Correct |
45 ms |
208 KB |
Output is correct |
33 |
Correct |
40 ms |
304 KB |
Output is correct |
34 |
Correct |
41 ms |
320 KB |
Output is correct |
35 |
Correct |
19 ms |
324 KB |
Output is correct |
36 |
Correct |
31 ms |
208 KB |
Output is correct |
37 |
Correct |
45 ms |
320 KB |
Output is correct |
38 |
Correct |
33 ms |
208 KB |
Output is correct |
39 |
Correct |
48 ms |
324 KB |
Output is correct |
40 |
Correct |
43 ms |
208 KB |
Output is correct |
41 |
Correct |
35 ms |
320 KB |
Output is correct |
42 |
Correct |
44 ms |
316 KB |
Output is correct |
43 |
Correct |
7 ms |
324 KB |
Output is correct |
44 |
Correct |
31 ms |
304 KB |
Output is correct |
45 |
Correct |
37 ms |
324 KB |
Output is correct |
46 |
Correct |
25 ms |
324 KB |
Output is correct |
47 |
Correct |
20 ms |
208 KB |
Output is correct |
48 |
Correct |
25 ms |
208 KB |
Output is correct |