이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "insects.h"
using namespace std;
const int N = 2e3 + 10;
int n;
bool bad[N];
bool check(int mid)
{
for(int i = 0 ; i < n ; i++)
{
bad[i] = false;
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])
move_outside(i);
for(int i = 0 ; i < n ; i++) if(bad[i])
{
move_inside(i);
int val = press_button();
if(val > 1)
move_outside(i);
}
bool flg = false;
for(int i = 0 ; i < n ; i++) if(!bad[i])
{
move_inside(i);
int val = press_button();
if(val == 1)
{
flg = true;
}
move_outside(i);
}
for(int i = 0 ; i < n ; i++) if(bad[i])
move_outside(i);
return flg;
}
int min_cardinality(int nn)
{
n = nn;
int low = 0 , high = n;
while(high - low > 1)
{
int mid = (low + high) >> 1;
if(check(mid))
high = mid;
else
low = mid;
}
return high;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |