Submission #787750

#TimeUsernameProblemLanguageResultExecution timeMemory
787750AndreyRarest Insects (IOI22_insects)C++17
0 / 100
4 ms220 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);
    vector<int> wut(0);
    vector<int> yay(0);
    int br = n;
    for(int i = 0; i < n; i++) {
        if(idk[i]) {
            move_inside(i);
            if(press_button() > a) {
                bruh[i] = false;
                yay.push_back(i);
                move_outside(i);
                br--;
            }
            else {
                wut.push_back(i);
            }
        }
    }
    if(br == p*a) {
        for(int i = 0; i < wut.size(); i++) {
            idk[wut[i]] = false;
        }
        for(int i = 0; i < yay.size(); i++) {
            idk[yay[i]] = false;
        }
        return false;
    }
    else {
        for(int i = 0; i < n; i++) {
            if(bruh[i] && idk[i]) {
                move_outside(i);
            }
        }
        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;
}

Compilation message (stderr)

insects.cpp: In function 'bool check(int)':
insects.cpp:28:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         for(int i = 0; i < wut.size(); i++) {
      |                        ~~^~~~~~~~~~~~
insects.cpp:31:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |         for(int i = 0; i < yay.size(); i++) {
      |                        ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...