# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
52123 | rondojim | Cave (IOI13_cave) | C++17 | 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 <bits/stdc++.h>
#include "cave.h"
using namespace std;
const int MAXN = 5e3 + 5;
int st[MAXN], con[MAXN], cnt;
int tryCombination(int S[]);
void answer(int S[], int D[]);
void solve(int ret){
int lo = 1, hi = N, mid, res, r;
while(lo <= hi){
mid = (lo + hi)>>1;
for(int i=1; i<=mid; ++i) st[i] ^= 1;
r = tryCombination(st);
for(int i=1; i<=mid; ++i) st[i] ^= 1;
if(r != ret) hi = mid - 1, res = mid;
else lo = mid + 1;
}
st[res] ^= 1;
}
void exploreCave(int N){
while(true){
int ret = tryCombination(st);
if(ret == -1){
for(int i=1; i<=N; ++i){ st[i] ^= 1; con[i] = tryCombination(st); st[i] ^= 1; }
break;
}
solve(ret);
}
}