# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
758631 | KN200711 | Cave (IOI13_cave) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "cave.h"
# include <bits/stdc++.h>
using namespace std;
int pos[5001], fn[5001], cek[5001];
void exploreCave(int N) {
for(int i=0;i<N;i++) pos[i] = -1;
for(int i=0;i<N;i++) {
// cari posisinya dimana skrg
for(int k=0;k<N;k++) {
if(pos[k] == -1) cek[k] = 0;
else cek[k] = pos[k];
}
int v = tryCombination(cek);
bool P;
if(v <= i) P = 1;
else P = 0;
int ans = -1, l = 0, r = N - 1;
while(l <= r) {
int mid = (l + r) / 2;
for(int d=0;d<mid;d++) {
if(pos[d] == -1) cek[d] = 1 - cek[d];
}
int sv = tryCombination(cek);
bool Q;
if(sv <= i) {
Q = 1;
} else Q = 0;
if(P == Q) {
ans = mid;
r = mid - 1;
} else {
l = mid + 1;
}
for(int d=0;d<mid;d++) {
if(pos[d] == -1) cek[d] = 1 - cek[d];
}
}
pos[mid] = P;
fn[mid] = i;
}
answer(pos, fn);
}