Submission #826345

# Submission time Handle Problem Language Result Execution time Memory
826345 2023-08-15T13:16:33 Z LittleCube Rarest Insects (IOI22_insects) C++17
0 / 100
0 ms 208 KB
#include "insects.h"
#include <bits/stdc++.h>
#define ll long long
using namespace std;

const double r = 0.45;

int min_cardinality(int N)
{
    vector<int> remain;
    int g = 0;
    {
        vector<int> single;
        for (int i = 0; i < N; i++)
        {
            move_inside(i);
            if (press_button() == 2)
                move_outside(i);
            else
                single.emplace_back(i), g++;
        }
        for (int i : single)
            move_outside(i);
    }
    int L = 1, R = N / g;
    for (int i = 0; i < N; i++)
        remain.emplace_back(i);
    int lazy = 0;
    while (L < R)
    {
        int k = L * (1.0 - r) + R * r;
        vector<int> small, large;

        for (int i : remain)
        {
            move_inside(i);
            if (press_button() > k)
            {
                move_outside(i);
                large.emplace_back(i);
            }
            else
                small.emplace_back(i);
        }
        if (small.size() + lazy == g * k)
            L = k + 1, remain = large, lazy = g * k;
        else
        {
            for (int i : small)
                move_outside(i);
            R = k, remain = small;
        }
    }
    return L;
}

Compilation message

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:45:33: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   45 |         if (small.size() + lazy == g * k)
      |             ~~~~~~~~~~~~~~~~~~~~^~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Incorrect 0 ms 208 KB Wrong answer.
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Incorrect 0 ms 208 KB Wrong answer.
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Wrong answer.
2 Halted 0 ms 0 KB -