Submission #932535

# Submission time Handle Problem Language Result Execution time Memory
932535 2024-02-23T15:21:11 Z velislavgarkov Rarest Insects (IOI22_insects) C++17
0 / 100
1 ms 596 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) {
    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:18:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   18 |     if (ss+last.size()==d*x) return true;
      |         ~~~~~~~~~~~~~~^~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 596 KB Wrong answer.
3 Halted 0 ms 0 KB -