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 <iostream>
#define pb push_back
using namespace std;
const int N = 5005;
int s[N],d[N],mx[N],s1[N],s2[N],n;
bool f[N];
int opp(int l,int r){
for (int i = 0; i < n; i++){
s1[i] = s[i];
if (f[i]) continue;
if (l <= i && i <= r) s1[i] = 1 - s1[i];
}
return tryCombination(s1);
}
void exploreCave(int N) {
n=N;
for (int i = 0; i < N; i++){
for (int j = 0; j < N; j++){
s1[j] = s2[j] = s[j];
if (f[j]) continue;
s1[j] = 0;
s2[j] = 1;
}
bool q = 0;
if (tryCombination(s1) == i) {
for (int j =0;j<N;j++)
s[j] = s1[j];
}
else {
q=1;
for (int j =0;j<N;j++)
s[j] = s2[j];
}
int l = 0,r = N - 1,res=-1;
while (l <= r){
int mid = (l + r)/2;
if (opp(l,mid) != i) res = mid, r = mid-1;
else l = mid + 1;
}
f[res] = 1;
d[res] = i;
if (q) s[res] = 0;
else s[res] = 1;
}
answer(s,d);
}
# | 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... |