Submission #1232155

#TimeUsernameProblemLanguageResultExecution timeMemory
1232155inesfiRarest Insects (IOI22_insects)C++20
0 / 100
0 ms416 KiB
#include "insects.h"
#include<bits/stdc++.h>
using namespace std;

// void move_inside(int i)
// void move_outside(int i)
// int press_button()

const int TAILLEMAXI=2002;
bool trouve[TAILLEMAXI];
int cb[TAILLEMAXI];
vector<int> diff;

int min_cardinality(int N) {
    trouve[0]=true;
    move_inside(0);
    int nbdiff=1;
    cb[0]=1;
    diff.push_back(0);
    for (int i=1;i<N;i++){
        move_inside(i);
        int nouv=press_button();
        if (nouv==1){
            nbdiff++;
            trouve[i]=1;
            cb[i]=1;
            diff.push_back(i);
        }
        else {
            move_outside(i);
        }
    }
    for (auto i:diff){
        move_outside(i);
    }
    for (int i=0;i<N;i++){
        if (trouve[i]==false){
            move_inside(i);
            int indice=0;
            bool ok=false;
            while (ok==false){
                move_inside(diff[indice]);
                if (press_button()==1){
                    cb[diff[indice]]++;
                    ok=true;
                    move_outside(diff[indice]);
                }
                else {
                    move_outside(diff[indice]);
                    indice++;
                }
            }
            trouve[i]=true;
        }
    }
    int rep=1000*1000;
    for (auto i:diff){
        rep=min(rep,cb[i]);
    }
    return rep;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...