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;
const int MAXM = 5005;
int M;
int pos[MAXM];
int loc[MAXM];
int cur;
int ex[MAXM];
void found(int known, int L, int R) {
for(int x = 0; x < M; x++) {ex[x] = 1-known;}
for(int x = L; x <= R; x++) {ex[x] = known;}
for(int x = 0; x < cur; x++) {ex[loc[x]] = pos[x];}
}
void exploreCave(int N) {
M = N;
int check[M];
for(int i = 0; i < M; i++) {pos[i] = -1; loc[i] = -1;}
int curpos;
int res;
for(cur = 0; cur < M; cur++) {
found(0, 0, M-1);
for(int j = 0; j < M; j++) {
check[j] = ex[j];
}
res = tryCombination(check);
curpos = 0;
if(res == cur) {curpos = 1;}
pos[cur] = curpos;
int lo = 0, hi = M-1;
int mi;
while(hi != lo) {
mi = (lo+hi)/2;
found(curpos,lo,mi);
for(int j = 0; j < M; j++) {check[j] = ex[j];}
res = tryCombination(check);
if(res == cur) {lo = mi+1;}
else hi = mi;
}
loc[cur] = lo;
}
int ansloc[M];
int anspos[M];
for(int i = 0; i < M; i++) {
ansloc[i] = loc[i];
anspos[loc[i]] = pos[i];
}
answer(anspos, ansloc);
}
# | 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... |