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"
void exploreCave(int N) {
int switch_position[N], doors[N], query_switch[N];
int closed, curr_switch_pos;
for(int i = 0; i<N; i++) {
switch_position[i] = 0;
query_switch[i] = 0;
doors[i] = -1;
}
for(int i = 0, beg = 0, end = N-1; i<N; i++, beg = 0, end = N-1) {
closed = tryCombination(switch_position);
if(closed!=i)
curr_switch_pos = 0;
else
curr_switch_pos = 1;
for(int mid = (N-1)/2; beg<end; mid = (beg+end)/2) {
for(int j = beg; j<=mid; j++)
if(doors[j]==-1)
query_switch[j] = 1 - curr_switch_pos;
for(int j = mid+1; j<=end; j++)
if(doors[j]==-1)
query_switch[j] = curr_switch_pos;
closed = tryCombination(query_switch);
for(int j = beg; j<=mid; j++)
if(doors[j]==-1)
query_switch[j] = 0;
for(int j = mid+1; j<=end; j++)
if(doors[j]==-1)
query_switch[j] = 0;
if(closed==i)
end = mid;
else
beg = mid+1;
}
doors[beg] = i;
switch_position[beg] = curr_switch_pos;
query_switch[beg] = curr_switch_pos;
}
answer(switch_position, doors);
}
# | 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... |