Submission #787706

#TimeUsernameProblemLanguageResultExecution timeMemory
787706AndreyRarest Insects (IOI22_insects)C++17
0 / 100
5 ms208 KiB
#include "insects.h"
#include<bits/stdc++.h>
using namespace std;

int n,p = 0;
vector<bool> idk(10000,true);

bool check(int a) {
    vector<bool> bruh(n,true);
    int br = n;
    for(int i = 0; i < n; i++) {
        if(idk[i]) {
            move_inside(i);
            if(press_button() > a) {
                bruh[i] = false;
                move_outside(i);
                br--;
            }
        }
    }
    for(int i = 0; i < n; i++) {
        if(bruh[i]) {
            move_outside(i);
        }
    }
    if(br == p*a) {
        for(int i = 0; i < n; i++) {
            if(bruh[i] == false) {
                idk[i] = false;
            }
        }
        return false;
    }
    else {
        return true;
    }
}

int min_cardinality(int N) {
    n = N;
    int l = 1,m,r;
    vector<bool> bruh(n,true);
    for(int i = 0; i < n; i++) {
        move_inside(i);
        if(press_button() > 1) {
            move_outside(i);
            bruh[i] = false;
        }
        else {
            p++;
        }
    }
    r = n/p;
    if(p == 1) {
        return n;
    }
    for(int i = 0; i < n; i++) {
        if(bruh[i]) {
            move_outside(i);
        }
    }
    while(l < r) {
        m = (l+r+1)/2;
        if(check(m)) {
            r = m-1;
        }
        else {
            l = m;
        }
    }
    return l;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...