# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1060429 | parsadox2 | Rarest Insects (IOI22_insects) | C++17 | 65 ms | 668 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 <bits/stdc++.h>
#include "insects.h"
using namespace std;
const int N = 2e3 + 10 , Lg = 10;
int n , ans;
bool bad[N] , dead[N];
bool check(int mid)
{
//cout << "Check : " << mid << endl;
int all = 0;
for(int i = 0 ; i < n ; i++) if(!dead[i])
{
bad[i] = false;
all++;
move_inside(i);
int val = press_button();
if(val > mid)
{
bad[i] = true;
move_outside(i);
}
}
for(int i = 0 ; i < n ; i++) if(!bad[i] && !dead[i])
move_outside(i);
bool flg = true;
vector <int> vec;
int cnt = 0;
for(int i = 0 ; i < n ; i++) if(bad[i] && !dead[i])
{
//cout << "BAD " << i << endl;
flg = false;
move_inside(i);
int val = press_button();
if(val > 1)
{
move_outside(i);
cnt++;
}
else
{
cnt += (mid + 1);
vec.push_back(i);
}
}
for(auto u : vec)
{
move_outside(u);
}
if(cnt == all)
{
for(int i = 0 ; i < n ; i++) if(!dead[i] && !bad[i])
dead[i] = true;
return false;
}
for(int i = 0 ; i < n ; i++) if(bad[i] && !dead[i])
dead[i] = true;
return true;
}
int min_cardinality(int nn)
{
n = nn;
int cnt = 0;
vector <int> vec;
for(int i = 0 ; i < n ; i++)
{
move_inside(i);
int val = press_button();
if(val == 1)
{
cnt++;
vec.push_back(i);
}
else
{
move_outside(i);
}
}
for(auto u : vec)
move_outside(u);
//cout << cnt << endl;
int mx = n / cnt;
while(mx > 1)
{
int mid = mx / 2;
if(!check(mid))
{
mx = mx - mid;
ans += mid;
}
else
{
mx = mid;
}
}
return ans + 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... |