Submission #974997

# Submission time Handle Problem Language Result Execution time Memory
974997 2024-05-04T09:27:27 Z pirhosig Rarest Insects (IOI22_insects) C++17
0 / 100
33 ms 1456 KB
#include <bits/stdc++.h>
#include "insects.h"
using namespace std;



int min_cardinality(int N) {
    unordered_set<int> rem;

    for (int i = 0; i < N; ++i) {
        move_inside(i);
        if (press_button() > 1) {
            move_outside(i);
            rem.insert(i);
        }
    }
    int T = N - rem.size();

    int low = 1;
    int upp = N / T;
    while (low < upp) {
        int mid = (low + upp + 1) / 2;
        vector<int> curr;
        int cnt = 0;
        for (int a : rem) {
            cnt++;
            move_inside(a);
            if (press_button() > mid) move_outside(a);
            else curr.push_back(a);

            if ((mid - low) * T - curr.size() > rem.size() - cnt) break;
        }

        if (curr.size() == (mid - low) * T) {
            low = mid;
            for (int a : curr) rem.erase(a);
        }
        else {
            upp = mid - 1;
            rem.clear();
            for (int a : curr) {
                move_outside(a);
                rem.insert(a);
            }
        }
    }

    return low;
}

Compilation message

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:34:25: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |         if (curr.size() == (mid - low) * T) {
      |             ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 3 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 2 ms 344 KB Output is correct
9 Correct 3 ms 600 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Incorrect 3 ms 600 KB Wrong answer.
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 3 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 2 ms 344 KB Output is correct
9 Correct 3 ms 600 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Incorrect 3 ms 600 KB Wrong answer.
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 33 ms 708 KB Output is correct
8 Correct 9 ms 344 KB Output is correct
9 Correct 29 ms 980 KB Output is correct
10 Correct 23 ms 1456 KB Output is correct
11 Correct 20 ms 856 KB Output is correct
12 Correct 9 ms 600 KB Output is correct
13 Correct 22 ms 1360 KB Output is correct
14 Correct 31 ms 976 KB Output is correct
15 Correct 26 ms 1368 KB Output is correct
16 Incorrect 30 ms 956 KB Wrong answer.
17 Halted 0 ms 0 KB -