Submission #859229

# Submission time Handle Problem Language Result Execution time Memory
859229 2023-10-10T02:02:51 Z kim Rarest Insects (IOI22_insects) C++17
0 / 100
0 ms 344 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){
    stack<int> st;
    for(int i=1;i<=n;++i){
        in(i), st.push(i);
        if(press()>k) out(i),st.pop();
    }
    int cnt=st.size();
    while(!st.empty()){
        out(st.top());
        st.pop();
    }
    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),vec0.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:39:23: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   39 |         int mid=l+(r-l+1>>1);
      |                    ~~~^~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Integer 2 violates the range [0, 1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Integer 2 violates the range [0, 1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Integer 6 violates the range [0, 5]
2 Halted 0 ms 0 KB -