Submission #830913

# Submission time Handle Problem Language Result Execution time Memory
830913 2023-08-19T12:52:53 Z tolbi Rarest Insects (IOI22_insects) C++17
0 / 100
113 ms 420 KB
#include <bits/stdc++.h>
using namespace std;
mt19937 ayahya(chrono::high_resolution_clock().now().time_since_epoch().count());
#include "insects.h"
int min_cardinality(int n) {
    function<int(int)> f;
    set<int> olan;
    for (int i = 0; i < n; ++i)
    {
        olan.insert(i);
    }
    vector<int> kullandim;
    vector<int> kullanmadim;
    f = [&](int x)->int{
        int ans = 0;
        vector<int> crr;
        for (auto it : olan){
            crr.push_back(it);
            move_inside(it);
            if (press_button()>x){
                crr.pop_back();
                kullanmadim.push_back(it);
                move_outside(it);
            }
            else kullandim.push_back(it),ans++;
        }
        for (int i = 0; i < crr.size(); ++i)
        {
            move_outside(crr[i]);
        }
        return ans;
    };
    int diff = f(1);
    kullanmadim.clear();
    kullandim.clear();
    if (diff==1) return n;
    int l = 1, r = n;
    int hueh = 0;
    int hehe = 0;
    while (l<r){
        int mid = l+(r-l)/2;
        int hayda = f(mid-hehe);
        //cout<<l<<" "<<r<<" "<<mid<<" "<<hayda<<" "<<hueh<<endl;
        if (hayda+hueh<(mid*diff)){
            r=mid;
            for (auto &it : kullanmadim){
                olan.erase(it);
            }
        }
        else {
            l = mid+1;
            hueh+=hayda;
            hehe+=mid;
            for (auto &it : kullandim){
                olan.erase(it);
            }
        }
        kullandim.clear();
        kullanmadim.clear();
    }
    return l-1;
}

Compilation message

insects.cpp: In lambda function:
insects.cpp:27:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |         for (int i = 0; i < crr.size(); ++i)
      |                         ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 12 ms 208 KB Output is correct
8 Correct 7 ms 316 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Correct 5 ms 208 KB Output is correct
11 Correct 8 ms 316 KB Output is correct
12 Correct 7 ms 312 KB Output is correct
13 Correct 10 ms 308 KB Output is correct
14 Incorrect 6 ms 208 KB Wrong answer.
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 12 ms 208 KB Output is correct
8 Correct 7 ms 316 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Correct 5 ms 208 KB Output is correct
11 Correct 8 ms 316 KB Output is correct
12 Correct 7 ms 312 KB Output is correct
13 Correct 10 ms 308 KB Output is correct
14 Incorrect 6 ms 208 KB Wrong answer.
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Partially correct 1 ms 208 KB Output is partially correct
6 Partially correct 0 ms 208 KB Output is partially correct
7 Correct 20 ms 380 KB Output is correct
8 Partially correct 88 ms 408 KB Output is partially correct
9 Incorrect 113 ms 420 KB Wrong answer.
10 Halted 0 ms 0 KB -