Submission #938571

# Submission time Handle Problem Language Result Execution time Memory
938571 2024-03-05T10:21:21 Z irmuun Rarest Insects (IOI22_insects) C++17
0 / 100
1 ms 344 KB
#include<bits/stdc++.h>
#include "insects.h"
 
using namespace std;
 
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()

int min_cardinality(int n){
    int d=0;
    set<int>st;
    for(int i=0;i<n;i++){
        d++;
        move_inside(i);
        st.insert(i);
        int cnt=press_button();
        if(cnt>1){
            move_outside(i);
            st.erase(i);
            d--;
        }
    }
    for(auto i:st){
        move_outside(i);
    }
    int l=1,r=n;
    while(l<r){
        int mid=(l+r)/2;
        int len=0;
        st.clear();
        for(int i=0;i<n;i++){
            len++;
            move_inside(i);
            st.insert(i);
            int cnt=press_button();
            if(cnt>mid){
                len--;
                move_outside(i);
                st.erase(i);
            }
        }
        if(len==d*mid){
            l=mid+1;
        }
        else{
            r=mid;
        }
        for(auto i:st){
            move_outside(i);
        }
    }
    return l;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 344 KB Wrong answer.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 344 KB Wrong answer.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Wrong answer.
2 Halted 0 ms 0 KB -