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;
typedef long long ll;
typedef pair<int,int> pii;
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define mk make_pair
#define pb push_back
#define fr first
#define sc second
int rand(int a, int b) {
return rand()%(b-a+1) + a;
}
int min_cardinality(int N) {
vector<int> in(N);
int colors = 0;
srand(381723);
for(int i = 0; i < N; i++) {
move_inside(i);
in[i] = 1;
if(press_button() == 2) move_outside(i), in[i] = 0;
else colors++;
}
if(colors == 1) return N;
int l = 1, r = N/colors;
while(l <= r) {
int mid = l + (r-l+1)/4, qtd = 0;
if(r == 1) return 1;
for(int i = 0; i < N; i++) {
if(in[i]) {qtd++; continue;}
in[i] = 1;
move_inside(i);
if(press_button() > mid) move_outside(i), in[i] = 0;
else qtd++;
}
if(qtd == colors*mid) l = mid+1;
else {
r = mid-1;
for(int i = 0; i < N; i++) if(in[i]) move_outside(i), in[i] = 0;
}
}
return l-1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |