이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "insects.h"
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>
#define all(x) (x).begin(), (x).end()
#define xx first
#define yy second
using namespace std;
template<typename T, typename Pr = less<T>>
using pq = priority_queue<T, vector<T>, Pr>;
using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;
int min_cardinality(int n)
{
int group = 1;
move_inside(0);
set<int> sel = { 0, };
for (int i = 1; i < n; i++)
{
move_inside(i);
if (press_button() > 1)
{
move_outside(i);
continue;
}
sel.insert(i);
group++;
}
int lo = 1, hi = n / group;
int ans = n;
int sz = 1;
while (lo <= hi)
{
int mid = (lo + hi) / 2;
if (sz < mid)
{
for (int i = 0; i < n; i++)
{
if (sel.find(i) != sel.end())
continue;
move_inside(i);
int now = press_button();
if (now > mid)
{
move_outside(i);
continue;
}
sz = now;
sel.insert(i);
}
}
else if(sz > mid)
{
for (int i = 0; i < n; i++)
{
if (sel.find(i) == sel.end())
continue;
move_outside(i);
int now = press_button();
if (now < mid)
{
move_inside(i);
continue;
}
sz = now;
sel.erase(i);
}
}
if (sel.size() == mid * group)
{
ans = mid;
lo = mid + 1;
}
else
{
hi = mid - 1;
}
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:97:18: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
97 | if (sel.size() == mid * group)
| ~~~~~~~~~~~^~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |