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"
const int NN = 5001;
int S[NN], go[NN], col[NN], h[NN];
int find(int bas, int son, int ccc, int ind) {
if(bas == son) return bas;
int orta = (bas + son) >> 1;
for(int j = bas; j <= orta; j++)
if(h[j]) S[j] = col[j];
else S[j] = ccc;
for(int j = orta + 1; j <= son; j++)
if(h[j]) S[j] = col[j];
else S[j] = !ccc;
if(tryCombination(S) != ind)
return find(bas, orta, ccc, ind);
return find(orta+1, son, ccc, ind);
}
void exploreCave(int N) {
for(int i = 0; i < N; i++) {
for(int j = 0; j < N; j++)
if(h[j]) S[j] = col[j];
else S[j] = 0;
int ccc = 0;
if(tryCombination(S) == i)
ccc = 1;
int index = find(0, N - 1, ccc, i);
h[index] = 1;
go[index] = i;
col[index] = ccc;
}
answer(col, go);
}
# | 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... |