제출 #1334474

#제출 시각아이디문제언어결과실행 시간메모리
1334474gohchingjayk드문 곤충 (IOI22_insects)C++20
0 / 100
0 ms344 KiB
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;

signed min_cardinality(signed N) {
	using ll = long long;
	#define int ll

	bool placed[2005];
	int num_unique = 0;
	for (int i = 0; i < N; ++i) {
		move_inside(i);
		int call = press_button();
		if (call > 1) {
			move_outside(i);
		}
		else {
			placed[i] = true;
			num_unique++;
		}
	}
	
	// pigeonhole principle
	if (num_unique * 2 > N) return 1;
	
	constexpr int LOG = 9;
	int curr = 1;
	for (int l = LOG; l >= 0; --l) {
		int tgt = curr + (1 << l);
		
		set<int> this_iter;
		for (int j = 0; j < N; ++j) {
			if (placed[j]) continue;
			
			move_inside(j);
			int call = press_button();
			if (call > tgt) {
				move_outside(j); continue;
			}
			
			this_iter.emplace(j);
		}
		
		if (this_iter.size() == (num_unique << l)) {
			for (int i : this_iter) placed[i] = true;
			curr = tgt;
		}
		else {
			for (int i : this_iter) move_outside(i);
		}
	}

	return curr;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...