Submission #787486

# Submission time Handle Problem Language Result Execution time Memory
787486 2023-07-19T08:28:54 Z alexander707070 Rarest Insects (IOI22_insects) C++17
99.58 / 100
53 ms 564 KB
#include<bits/stdc++.h>
#include "insects.h"
#define MAXN 2007
using namespace std;
 
int n,cnt,ans,pt;
vector<int> diff,s,last,z;
int l[MAXN],r[MAXN],br[MAXN];
bool used[MAXN],in[MAXN],skip[MAXN];
vector< pair<int,int> > qr;
 
bool ok(int k){
    last.clear(); z.clear();
 
    for(int i=0;i<n;i++){
        if(used[i] or skip[i])continue;
 
        move_inside(i); cnt++;
        s.push_back(i); used[i]=true;
 
        last.push_back(i);
 
        if(press_button()>k){
            move_outside(i); cnt--;
            s.pop_back(); used[i]=false;
            last.pop_back();
            z.push_back(i);
        }
 
        if(cnt==k*int(diff.size()))return true;
    }
 
    for(int i:last){
        used[i]=false; move_outside(i);
        cnt--;
    }
    for(int i:z){
        skip[i]=true;
    }

    return false;
}
 
int min_cardinality(int N){
    n=N;
 
    for(int i=0;i<n;i++){
        move_inside(i);
        diff.push_back(i);
 
        if(press_button()>1){
            move_outside(i);
            diff.pop_back();
        }
    }
 
    for(int i:diff)move_outside(i);
 
    int l=1,r=n/int(diff.size())+2,tt;
 
    while(l+1<r){
        tt=(l+r)/2;
        if(ok(tt)){
            l=tt;
        }else{
            r=tt;
        }
    }
    
    return l;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 3 ms 304 KB Output is correct
7 Correct 3 ms 208 KB Output is correct
8 Correct 3 ms 208 KB Output is correct
9 Correct 6 ms 208 KB Output is correct
10 Correct 5 ms 208 KB Output is correct
11 Correct 3 ms 312 KB Output is correct
12 Correct 4 ms 208 KB Output is correct
13 Correct 4 ms 208 KB Output is correct
14 Correct 5 ms 308 KB Output is correct
15 Correct 4 ms 208 KB Output is correct
16 Correct 3 ms 208 KB Output is correct
17 Correct 5 ms 208 KB Output is correct
18 Correct 4 ms 208 KB Output is correct
19 Correct 5 ms 308 KB Output is correct
20 Correct 5 ms 208 KB Output is correct
21 Correct 3 ms 208 KB Output is correct
22 Correct 3 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 3 ms 304 KB Output is correct
7 Correct 3 ms 208 KB Output is correct
8 Correct 3 ms 208 KB Output is correct
9 Correct 6 ms 208 KB Output is correct
10 Correct 5 ms 208 KB Output is correct
11 Correct 3 ms 312 KB Output is correct
12 Correct 4 ms 208 KB Output is correct
13 Correct 4 ms 208 KB Output is correct
14 Correct 5 ms 308 KB Output is correct
15 Correct 4 ms 208 KB Output is correct
16 Correct 3 ms 208 KB Output is correct
17 Correct 5 ms 208 KB Output is correct
18 Correct 4 ms 208 KB Output is correct
19 Correct 5 ms 308 KB Output is correct
20 Correct 5 ms 208 KB Output is correct
21 Correct 3 ms 208 KB Output is correct
22 Correct 3 ms 208 KB Output is correct
23 Correct 12 ms 312 KB Output is correct
24 Correct 15 ms 308 KB Output is correct
25 Correct 18 ms 292 KB Output is correct
26 Correct 25 ms 208 KB Output is correct
27 Correct 16 ms 300 KB Output is correct
28 Correct 8 ms 308 KB Output is correct
29 Correct 19 ms 300 KB Output is correct
30 Correct 25 ms 296 KB Output is correct
31 Correct 21 ms 304 KB Output is correct
32 Correct 21 ms 304 KB Output is correct
33 Correct 17 ms 300 KB Output is correct
34 Correct 20 ms 208 KB Output is correct
35 Correct 21 ms 296 KB Output is correct
36 Correct 12 ms 336 KB Output is correct
37 Correct 23 ms 284 KB Output is correct
38 Correct 13 ms 296 KB Output is correct
39 Correct 22 ms 300 KB Output is correct
40 Correct 18 ms 308 KB Output is correct
41 Correct 13 ms 296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 252 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 32 ms 296 KB Output is correct
8 Correct 29 ms 304 KB Output is correct
9 Correct 30 ms 296 KB Output is correct
10 Correct 40 ms 328 KB Output is correct
11 Correct 28 ms 300 KB Output is correct
12 Correct 27 ms 300 KB Output is correct
13 Correct 32 ms 416 KB Output is correct
14 Correct 40 ms 296 KB Output is correct
15 Correct 24 ms 300 KB Output is correct
16 Correct 16 ms 308 KB Output is correct
17 Correct 26 ms 292 KB Output is correct
18 Correct 31 ms 304 KB Output is correct
19 Correct 35 ms 292 KB Output is correct
20 Correct 44 ms 284 KB Output is correct
21 Correct 38 ms 208 KB Output is correct
22 Partially correct 44 ms 288 KB Output is partially correct
23 Correct 53 ms 440 KB Output is correct
24 Correct 31 ms 312 KB Output is correct
25 Correct 26 ms 308 KB Output is correct
26 Correct 33 ms 312 KB Output is correct
27 Correct 41 ms 288 KB Output is correct
28 Correct 26 ms 304 KB Output is correct
29 Correct 20 ms 208 KB Output is correct
30 Correct 32 ms 304 KB Output is correct
31 Correct 38 ms 320 KB Output is correct
32 Partially correct 39 ms 328 KB Output is partially correct
33 Partially correct 42 ms 296 KB Output is partially correct
34 Correct 51 ms 308 KB Output is correct
35 Correct 37 ms 288 KB Output is correct
36 Correct 30 ms 288 KB Output is correct
37 Correct 47 ms 288 KB Output is correct
38 Correct 24 ms 564 KB Output is correct
39 Correct 39 ms 320 KB Output is correct
40 Correct 25 ms 284 KB Output is correct
41 Correct 44 ms 292 KB Output is correct
42 Correct 26 ms 284 KB Output is correct
43 Correct 10 ms 308 KB Output is correct
44 Correct 36 ms 288 KB Output is correct
45 Correct 33 ms 296 KB Output is correct
46 Correct 33 ms 292 KB Output is correct
47 Correct 37 ms 312 KB Output is correct
48 Correct 35 ms 312 KB Output is correct