이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;
int min_cardinality(int N)
{
int num_insects = 0;
set<int> s;
for(int i = 0; i < N; i++)
{
// cout << "moving inside[1]: " << i << endl;
move_inside(i);
s.insert(i);
num_insects++;
if(press_button() == 2)
{
// cout << "moving outside[1]: " << i << endl;
move_outside(i);
s.erase(i);
num_insects--;
}
}
// cout << "num_insects = " << num_insects << endl;
int l = 1, r = num_insects, ans = num_insects;
while(l <= r)
{
int mid = (l + r) / 2;
// cout << "mid = " << mid << endl;
// cout << "s.size() = " << s.size() << endl;
for(auto i: s)
{
// cout << "i = " << i << endl;
// cout << "moving outside[2]: " << i << endl;
move_outside(i);
}
s.clear();
// cout << "hello!" << endl;
int current_insects = 0;
for(int i = 0; i < N; i++)
{
// cout << "moving inside[3]: " << i << endl;
move_inside(i);
s.insert(i);
current_insects++;
if(press_button() > mid)
{
// cout << "moving outside[3]: " << i << endl;
move_outside(i);
s.erase(i);
current_insects--;
}
}
// cout << "current_insects = " << current_insects << endl;
if(current_insects == mid * num_insects)
{
ans = mid;
l = mid + 1;
}
else
{
r = mid - 1;
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |