이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "insects.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2010;
int par[maxn], rnk[maxn];
int used[maxn], diff, n;
vector < int > safe;
bool check(int x)
{
int cnt = safe.size();
vector < int > vec;
for (int i = 0; i < n && cnt != x * diff; i ++)
{
if (!used[i])
continue;
move_inside(i);
vec.push_back(i);
if (press_button() > x)
{
move_outside(i);
vec.pop_back();
}
else
{
cnt ++;
}
}
if (cnt != x * diff)
{
for (int i = 0; i < n; i ++)
used[i] = 0;
for (int v : vec)
used[v] = 1;
for (int v : vec)
move_outside(v);
}
else
{
for (int v : vec)
used[v] = 0, safe.push_back(v);
}
return cnt == x * diff;
}
int find_different(int N)
{
int cnt = 0;
vector < int > vec;
for (int i = 0; i < n; i ++)
{
move_inside(i);
vec.push_back(i);
if (press_button() > 1)
{
move_outside(i);
vec.pop_back();
}
else
{
cnt ++;
}
}
for (int v : vec)
move_outside(v);
return cnt;
}
int min_cardinality(int N)
{
n = N;
diff = find_different(N);
for (int i = 0; i < N; i ++)
used[i] = 1;
int lf = 0, rf = N;
rf = N / diff;
if (diff == 1)
return N;
while(lf <= rf)
{
int mf = (lf + rf) / 2;
if (check(mf))
lf = mf + 1;
else
rf = mf - 1;
}
return rf;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |