# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
971356 | Acanikolic | Cave (IOI13_cave) | C++14 | 232 ms | 600 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;
void exploreCave(int N) {
int S[N],D[N];
for(int i = 0; i < N; i++) {
S[i] = 0;
D[i] = -1;
}
for(int Q = 0; Q < N; Q++) {
int X = tryCombination(S);
int l = 0, r = N - 1,ans = -1,yy;
while(l <= r) {
int mid = (l + r) / 2;
for(int i = l; i <= mid; i++) if(D[i] == -1) S[i] ^= 1;
int Y = tryCombination(S);
for(int i = l; i <= mid; i++) if(D[i] == -1) S[i] ^= 1;
if(X != Y) {
yy = Y;
ans = mid;
r = mid - 1;
}else {
l = mid + 1;
}
}
assert(ans != -1);
D[ans] = X;
S[ans] ^= 1;
if(X == -1) {
D[ans] = yy;
S[ans] ^= 1;
}
else if(yy < X && yy != -1) {
D[ans] = yy;
S[ans] ^= 1;
}
}
answer(S,D);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |