| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1327793 | lucasdmy | 동굴 (IOI13_cave) | C++20 | 0 ms | 0 KiB |
//#include "cave.h"
#include <bits/stdc++.h>
using namespace std;
void exploreCave(int n){
vector<int>state(n, -1), resp(n, -1);
for(int k=0;k<n;k++){
int p1=0, p2=n-1, my_state=0;
vector<int>query(n);
for(int i=0;i<n;i++){
if(state[i]!=-1){
query[i]=state[i];
}else{
state[i]=0;
}
}
int aux=tryCombination(query);
if(aux==k){
my_state=1;
}
while(p1!=p2){
int m=(p1+p2)/2;
for(int i=0;i<n;i++){
if(state[i]!=-1){
query[i]=state[i];
}else if(p1<=i and i<=m){
state[i]=my_state;
}else{
state[i]=(my_state+1)%2;
}
}
if(tryCombination(query)==k){
p1=m+1;
}else{
p2=m;
}
}
state[p2]=my_state;
resp[p2]=k;
}
answer(state, resp);
}