| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1355999 | vjudge1 | 드문 곤충 (IOI22_insects) | C++20 | 0 ms | 0 KiB |
#include "insects.h"
#include<bits/stdc++.h>
using namespace std;
int min_cardinality(int N) {
for(int i=0;i<N;i++){
move_inside(i);
for(int j=i+1;j<N;j++){
move_inside(j);
if(j>=i+2)move_outside(j-1);
int val=press_button();
if(val==2)join(i,j);
}
move_outside(i);
move_outside(N-1);
}
int l=1,r=N;
while(l<r){
int ch=0;
int mid=(l+r)/2;
for(int i=0;i<N;i++){
move_inside(i);
ch=1;
for(int j=i+1;j<N;j++){
move_inside(j);
if(j>=i+2)move_outside(j-1);
int val=press_button();
if(val>mid){
move_outside(j);
ch=0;
break;
}
}
move_outside(i);
if(ch)break;
// move_outside(N-1);
}
if(ch)r=mid;
else l=mid+1;
}
return l;
}