# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
787841 | Andrey | Rarest Insects (IOI22_insects) | C++17 | 1 ms | 208 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "insects.h"
#include<bits/stdc++.h>
using namespace std;
int n,p = 0,l,r;
vector<bool> idk(10000,true);
vector<bool> no(10000,true);
void check(int a) {
vector<bool> bruh(n,true);
vector<int> wut(0);
vector<int> yay(0);
int br = n;
for(int i = 0; i < n; i++) {
if(idk[i] && no[i]) {
move_inside(i);
if(press_button() > a) {
bruh[i] = false;
yay.push_back(i);
move_outside(i);
br--;
}
else {
wut.push_back(i);
}
}
else if(no[i] == false) {
br--;
}
}
if(br == p*a) {
l = a+1;
for(int i = 0; i < wut.size(); i++) {
idk[wut[i]] = false;
}
return;
}
else {
r = a;
if(l == r) {
return;
}
for(int i = 0; i < n; i++) {
if(bruh[i] && idk[i] && no[i]) {
move_outside(i);
}
}
for(int i = 0; i < yay.size(); i++) {
no[yay[i]] = false;
}
return;
}
}
int min_cardinality(int N) {
n = N;
int m;
l = 1;
vector<bool> bruh(n,true);
vector<int> yay(0);
for(int i = 0; i < n; i++) {
move_inside(i);
if(press_button() > 1) {
move_outside(i);
bruh[i] = false;
}
else {
p++;
yay.push_back(i);
}
}
for(int i = 0; i < p; i++) {
idk[yay[i]] = false;
}
r = n/p;
if(p == 1) {
return n;
}
while(l < r) {
m = (l+r)/2;
check(m);
}
return l-1;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |