이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#include "insects.h"
using namespace std;
template<typename T> bool ckmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
int min_cardinality(int N) {
	vector<int> groups{0};
	move_inside(0);
	for (int i = 1; i < N; i++) {
		move_inside(i);
		if (press_button() > 1) move_outside(i);
		else groups.push_back(i);
	}
	vector<int> pot(N);
	iota(all(pot), 0);
	int l = 2, r = sz(pot) / sz(groups), ans = 1;
	vector<int> got{groups};
	while (l <= r) {
		int mid = (l+r)/2;
		auto orig = got;
		for (int x : pot) {
			if (find(all(got), x) != got.end()) { 
				continue;
			}
			move_inside(x);
			if (press_button() > mid) move_outside(x);
			else got.push_back(x);
		}
		if (sz(got) == mid * sz(groups)) { 
			ans = mid, l = mid+1;
		}
		else { 
			r = mid-1;
			for (int x : got) move_outside(x);
			swap(pot, got);
			swap(got, orig);
		}
	}
	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... |