Submission #867573

# Submission time Handle Problem Language Result Execution time Memory
867573 2023-10-28T19:51:27 Z imarn Rarest Insects (IOI22_insects) C++17
0 / 100
0 ms 344 KB
#include<bits/stdc++.h>
#include "insects.h"
#define f first
#define s second
#define pb push_back
using namespace std;
int siz[2001]{0};
int min_cardinality(int N) {
    vector<int>vec;
    int vis[2001]={0};
    int use[2001]={0};
    move_inside(0);
    int sz=0;
    for(int i=0;i<N;i++)siz[i]=1;
    for(int i=0;i<N;i++){
    	if(vis[i])continue;
        move_inside(i);
        if(press_button()==1){
            vis[i]=1;sz++;vec.pb(i);
        }
        else move_outside(i);
    }
    int l=1,r=N/sz+1;
    int mx=sz;
    int ans=1;
    while(l<r){
        int m=(l+r+1)>>1;
        int cnt=0;
        for(int i=0;i<N;i++){
            if(cnt==mx*(m-ans))break;
            if(!vis[i]){
                move_inside(i);
                if(press_button()<=m)cnt++,use[i]=1;
                else move_outside(i),vis[i]=1,use[i]=1;
            }
        }
        if(cnt==mx*(m-ans)){
            l=m;ans=m;
            for(int i=0;i<N;i++)if(use[i]&&!vis[i])vis[i]=!vis[i];
            for(int i=0;i<N;i++)if(vis[i]&&use[i])vis[i]=!vis[i];
        }
        else {
            r=m-1;
            for(int i=0;i<N;i++)if(use[i]&&!vis[i])move_outside(i);
        }memset(use,0,sizeof use);
    }return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Wrong answer.
3 Halted 0 ms 0 KB -