| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1310662 | lizi14 | 동굴 (IOI13_cave) | C++20 | 0 ms | 0 KiB |
#include <iostream>
#include <bits/stdc++.h>
#include <fstream>
#include <cstdlib>
#include <cstdio>
#include "cave.h"
using namespace std;
void exploreCave(int N) {
vector<int>x(N,1),s(N,0),c(N,0);
int an=0;
int f=0;
int h=0;
int ans=0;
while(h<N){
int l=0,r=N;
while(r-l>1){
int mid=(l+r)/2;
for(int i=l; i<mid; i++){
if(s[i]==0){
x[i]=1-x[i];
}
}
int k=tryCombination(x);
for(int i=l; i<mid; i++){
if(s[i]==0){
x[i]=1-x[i];
}
}
if(k==-1 || k>h){
l=mid;
//ans=l;
}
else{
r=mid;
}
//else r=mid-1;
}
ans=l;
x[ans]=0;
if(tryCombination(x)==h)x[ans]=1;
s[ans]=1;
c[ans]=h;
// an=a;
// //x[ans]=1-x[ans];
// s[ans]=1;
// c[ans]=h;
// for(int i=0; i<N; i++){
// if(s[i]==0){
// x[i]=0;
// }
// }
h++;
}
//h++;
// else{
// for(int i=0; i<N; i++){
// if(s[i]==0){
// x[i]=1-x[i];
// //f=x[i];
// }
// }
// }
// for(int i=0; i<N; i++){
// cout<<x[i]<<" ";
// }
// cout<<endl;
//x[a]=1-x[a];
return answer(x, c);
}
