Submission #932543

# Submission time Handle Problem Language Result Execution time Memory
932543 2024-02-23T15:27:42 Z velislavgarkov Rarest Insects (IOI22_insects) C++17
0 / 100
34 ms 932 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();
    if (!removed.empty()) removed.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:20:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |     if (ss+last.size()==d*x) return true;
      |         ~~~~~~~~~~~~~~^~~~~
# 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 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 596 KB Output is correct
6 Correct 3 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 3 ms 344 KB Output is correct
9 Incorrect 3 ms 344 KB Wrong answer.
10 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 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 596 KB Output is correct
6 Correct 3 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 3 ms 344 KB Output is correct
9 Incorrect 3 ms 344 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 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 34 ms 600 KB Output is correct
8 Correct 7 ms 344 KB Output is correct
9 Correct 27 ms 932 KB Output is correct
10 Correct 24 ms 420 KB Output is correct
11 Correct 24 ms 428 KB Output is correct
12 Correct 13 ms 700 KB Output is correct
13 Incorrect 26 ms 856 KB Wrong answer.
14 Halted 0 ms 0 KB -