Submission #859224

# Submission time Handle Problem Language Result Execution time Memory
859224 2023-10-10T01:58:30 Z kim Rarest Insects (IOI22_insects) C++17
Compilation error
0 ms 0 KB
#include "insects.h"
#include<bits/stdc++.h>

using namespace std;

#define in move_inside
#define press press_button
#define out move_outside

vector<int> vec0;
int p;
int n;

bool check(int k){
    int cnt=0;
    for(int i=1;i<=n;++i){
        in(i), ++cnt;
        if(press()>k) out(i),--cnt;
    }
    if(cnt==p*k) return 1;
    return 0;
}

int min_cardinality(int N){
    n=N;
    for(int i=1;i<=n;++i){
        in(i), vec0.push_back(i);
        if(press()>1) out(i),vec.pop_back();
    }
    p=vec0.size();

    int l=1,r=n/p;
    while(l<r){
        int mid=l+(r-l+1>>1);
        if(check(mid)) l=mid;
        else r=mid-1;
    }
    return l;
}

Compilation message

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:28:30: error: 'vec' was not declared in this scope; did you mean 'vec0'?
   28 |         if(press()>1) out(i),vec.pop_back();
      |                              ^~~
      |                              vec0
insects.cpp:34:23: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   34 |         int mid=l+(r-l+1>>1);
      |                    ~~~^~