Submission #932537

# Submission time Handle Problem Language Result Execution time Memory
932537 2024-02-23T15:23:42 Z velislavgarkov Rarest Insects (IOI22_insects) C++17
0 / 100
38 ms 1108 KB
#include "insects.h"
#include <iostream>
#include <vector>
using namespace std;
const int MAXN=1e4;
bool used[MAXN];
vector <int> last, removed;
int n, ss, d;
bool check(int x) {
    if (!last.empty()) last.clear();
    for (int i=0;i<n;i++) {
        if (used[i]) continue;
        move_inside(i);
        if (press_button()>x) {
            move_outside(i);
            removed.push_back(i);
        } else last.push_back(i);
    }
    if (ss+last.size()==d*x) return true;
    return false;
}
int min_cardinality(int N) {
    n=N;
    d=0;
    for (int i=0;i<n;i++) {
        move_inside(i);
        if (press_button()>1) move_outside(i);
        else {
            used[i]=true;
            d++;
        }
    }
    ss=d;
    int l, r, mid;
    l=1; r=n/d+1;
    while (l<r-1) {
        mid=(l+r)/2;
        if (check(mid)) {
            l=mid;
            ss+=last.size();
            for (auto i:last) used[i]=true;
        } else {
            r=mid-1;
            for (auto i:removed) used[i]=true;
        }
    }
    if (check(r)) return r;
    return l;
}

Compilation message

insects.cpp: In function 'bool check(int)':
insects.cpp:19:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   19 |     if (ss+last.size()==d*x) return true;
      |         ~~~~~~~~~~~~~~^~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 340 KB Output is correct
6 Correct 3 ms 600 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 3 ms 440 KB Output is correct
9 Incorrect 3 ms 600 KB Wrong answer.
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 340 KB Output is correct
6 Correct 3 ms 600 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 3 ms 440 KB Output is correct
9 Incorrect 3 ms 600 KB Wrong answer.
10 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 0 ms 344 KB Output is correct
7 Correct 31 ms 700 KB Output is correct
8 Correct 11 ms 344 KB Output is correct
9 Correct 38 ms 684 KB Output is correct
10 Correct 27 ms 672 KB Output is correct
11 Correct 25 ms 680 KB Output is correct
12 Correct 14 ms 676 KB Output is correct
13 Incorrect 26 ms 1108 KB Wrong answer.
14 Halted 0 ms 0 KB -