제출 #1191457

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

using namespace std;

int min_cardinality(int N) {
	int ans = N;
	int d = 0;
	int allN = N;
	vector<int> allIdx(N);
	for (int i = 0; i < N; i++){
		allIdx[i] = i;
	}
	for (int i = 0; i < allN; i++){
		move_inside(allIdx[i]);
		int count = press_button();
		if (count > 1){
			move_outside(allIdx[i]);
		}
		else{
			allIdx.erase(allIdx.begin() + i);
			i--;
			d++;
		}
	}
	int curAmount = d;
	for (int m = 2; m <= N; m++){
		for (int i = 0; i < allN; i++){
			move_inside(allIdx[i]);
			int count = press_button();
			if (count > m){
				move_outside(allIdx[i]);
			}
			else{
				allIdx.erase(allIdx.begin() + i);
				i--;
				curAmount++;
				if (curAmount == d * m) break;
			}
		}
		if (d * m > curAmount){
			return m - 1;
		}
	}
	return N;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...