# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
485349 | silverfish | 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 s[5005], curs[5005], door[5005];
int getstate(int comb, int i){
return (comb > i || comb==-1);
}
void setcurs(int b, int f, int val){
for(int i = b; i < f; ++i){
if(~s[k]) curs[k] = s[k];
else curs[k] = val;
}
}
void exploreCave(int N) {
fill(s, s+N, -1);
for(int i = 0; i < N; ++i){
setcurs(0, N, 0);
int d = 0, state = getstate(tryCombinations(curs), i);
for(int j = 12; j >= 0; --j){
setcurs(d, min(d + (1<<j), N), 1);
if(getstate(tryCombination(curs), i) == state) d = min(d + (1<<j), N-1);
else setcurs(d, min(d + (1<<j), N), 0);
}
door[d] = i;
s[d] = (state ? 0 : 1);
}
answer(s, door);
}