# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
658481 | coding_snorlax | 드문 곤충 (IOI22_insects) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "insects.h"
#include<bits/stdc++.h>
using namespace std;
int All_type[2000]={0};
int Box[2000]={0};
int Check[2000]={0};
int All_possible[2000];
int Total_N;
int level_1;
int check(int Num){
//cout<<Total_N<<"Total_N"<<endl;
int tmp;
for(int j=0;j<Total_N;j++){
//cout<<"All_possible "<<All_possible[j]<<" Check "<<Check[j]<<endl;
if(All_possible[j] && !Check[j]){
//cout<<j<<endl;
move_inside(j);
tmp=press_button();
if(tmp>Num){
move_outside(j);
}
else{
//now_active
Check[j]=2;
}
}
}
int Count=0;
for(int j=0;j<Total_N;j++){
if(Check[j]) {
Count++;
}
}
if(Count<level_1*Num){
for(int j=0;j<Total_N;j++){
if(Check[j]==2){
move_outside(j);
Check[j]=0;
}
else if(!Check[j]) All_possible[j]=0;
}
return 0;
}
for(int j=0;j<Total_N;j++){
if(Check[j]==2){
Check[j]=1;
}
}
return 1;
}
int min_cardinality(int N){
Total_N=N;
for(int j=0;j<N;j++){
All_possible[j]=1;
}
for(int j=0;j<N;j++){
int tmp;
if(!All_type[j]){
move_inside(j);
tmp=press_button();
if(tmp>1){
move_outside(j);
}
else{
Check[j]=1;
}
}
}
int Count=0;
for(int j=0;j<N;j++){
if(Check[j]==1) {
move_outside(j);
Check[j]=0;
Count++;
}
}
level_1=Count;
//binary_search
int L=1,R=N/level_1;
while(L!=R){
if((R-L)<=2){
if(check(L+1)){
if(check(L+2)) return L+2;
return L+1;
}
return L;
}
if((R-L)%2==1){
int M=(L+R)/2+1;
}
else{
int M=(L+R)/2;
}
if(check(M)) L=M;
else R=M+1;
}
return L;
}