# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
806668 | Ronin13 | 드문 곤충 (IOI22_insects) | C++17 | 67 ms | 416 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 f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
using namespace std;
int d;
int min_cardinality(int n) {
vector <int> act;
bool used[n + 1];
fill(used, used + n + 1, false);
for(int i = 0; i < n; i++){
move_inside(i);
int x = press_button();
if(x == 2) move_outside(i);
else act.pb(i);
}
//for(int to : act) cout << to << ' ';
//int l = 0, r = act.size();
for(int to : act) move_outside(to);
int d = act.size();
int l = 1, r = n / d;
vector <int> cur;
while(l != r){
int mid = (l + r + 1) / 2;
vector <int> vv;
for(int i = 0; i < n; i++){
if(used[i]) continue;
int cnt = 0;
for(int i = 0; i < n; i++){
if(!used[i]) cnt++;
}
if(cnt < d) break;
move_inside(i);
int x = press_button();
if(x > mid) move_outside(i);
else vv.pb(i);
if(vv.size() + cur.size() == mid * d) break;
}
int x = cur.size() + vv.size();
if(x == mid * d){
l = mid;
for(int to : vv) used[to] = true, cur.pb(to);
}
else{
r = mid - 1;
for(int i = 0; i < n; i++) used[i] =true;
for(int to : vv) used[to] = false, move_outside(to);
}
}
return l;
}
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... |