# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
631749 | AmirElarbi | Rarest Insects (IOI22_insects) | C++17 | 188 ms | 412 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 ve vector
#define vi ve<int>
#define ii pair<int,int>
#define ll long long
#define vvi ve<vi>
#define se second
#define fi first
#define pb push_back
using namespace std;
const int nax = 2e3+5;
const int MOD = 1e9+7;
int pref[nax];
int min_cardinality(int n) {
int type = 0;
for (int i = 0; i < n; ++i)
{
move_inside(i);
int a = press_button();
if(a == 1)
type++;
else
move_outside(i);
pref[i] = type;
}
for (int i = 0; i < n; ++i)
{
move_outside(i);
}
int l = 1,r = n/type+1, ans = 0;
vi cur, vis(n);
while(l< r){
int md = (l+r)/2;
for (int i = 0; i < n; ++i)
{
if(vis[i]) continue;
move_inside(i);
int a = press_button();
if(a > md){
move_outside(i);
} else {
cur.pb(i);
}
}
if(type*md == cur.size()){
for(auto x : cur) vis[x] = 1;
l = md+1; ans = md;
} else {
r = md;
vi nw;
for (auto i : cur)
{
if(vis[i]){
nw.pb(i);
continue;
}
move_outside(i);
}
cur.clear();
for(auto x : nw) cur.pb(x);
}
}
return ans;
}
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... |