# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
726983 | murad_2005 | Rarest Insects (IOI22_insects) | C++17 | 71 ms | 472 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>
#define ll long long
#define ull unsigned ll
#define pii pair<int, int>
#define piii pair<int, pii>
#define pb push_back
#define all(v) v.begin(), v.end()
#define size(v) v.size()
#define f first
#define s second
#define INF 1e9
using namespace std;
int min_cardinality(int N) {
vector<int>inside(N, false);
vector<int>fixed(N, false);
set<int>Machine;
for(int i = 0; i < N; ++i){
move_inside(i);
if(press_button() > 1){
move_outside(i);
}else{
Machine.insert(i);
inside[i] = fixed[i] = true;
}
}
int uni = size(Machine);
int low = 2, high = N / uni, Res = 1;
while(low <= high){
int mid = (low + high) >> 1;
for(int i = 0; i < N; ++i){
if(uni * mid == size(Machine)) break;
if(!fixed[i]){
move_inside(i);
if(press_button() > mid){
move_outside(i);
}else{
Machine.insert(i);
inside[i] = true;
}
}
}
if(uni * mid == size(Machine)){
low = mid + 1;
Res = mid;
for(int i = 0; i < N; ++i){
if(inside[i]) fixed[i] = true;
}
}else{
high = mid - 1;
for(int i = 0; i < N; ++i){
if(!inside[i]) fixed[i] = true;
else if(!fixed[i]){
move_outside(i);
Machine.erase(i);
inside[i] = false;
}
}
}
}
return Res;
}
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... |