답안 #1079535

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1079535 2024-08-28T16:27:10 Z Lalic 드문 곤충 (IOI22_insects) C++17
0 / 100
0 ms 344 KB
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define mp make_pair

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef complex<double> cd;

int min_cardinality(int N) {
	queue<int> q;
	
	int tipos=0;
	for(int i=0;i<N;i++){
		move_inside(i);
		int curr=press_button();
		
		if(curr>=2) move_outside(i);
		else{
			tipos++;
			q.push(i);
		}
	}
	
	while(!q.empty()){
		move_outside(q.front());
		q.pop();
	}
	
	int low=1, high=N-1, best=N;
	while(low<=high){
		int mid=(low+high)>>1;
		
		while(!q.empty()){
			move_outside(q.front());
			q.pop();
		}
		
		int qnt=0;
		for(int i=0;i<N;i++){
			move_inside(i);
			int curr=press_button();
			
			if(curr>mid) move_outside(i);
			else{
				qnt++;
				q.push(i);
			}
		}
		
		if(qnt/mid==tipos){
			best=mid;
			low=mid+1;
		}
		else high=mid-1;
	}
	
	return best;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Wrong answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Wrong answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Wrong answer.
3 Halted 0 ms 0 KB -