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;
int com[] = {1,1,1,1};
int bruh[] = {0,1,2,3};
int n;
/*
int tryCombination(int A[]){
for(int i=0;i<n;i++) cout<<A[i]<<" ";
cout<<"\n";
for(int i=0;i<n;i++){
if(A[i]!=com[bruh[i]]) {cout<<"i"<<i;return i;}
}
cout<<-1;
return -1;
return 1;
}
void answer(int A[],int B[]){
cout<<"H"<<endl;
for(int i=0;i<n;i++) cout<<A[i]<<" ";
cout<<endl;
for(int i=0;i<n;i++) cout<<B[i]<<" ";
}*/
void exploreCave(int N) {
n = N;
int comb[N+3];
int link[N+3];
memset(comb,-1,sizeof(comb));
memset(link,-1,sizeof(link));
for(int i=0;i<N;i++){
int tr[N+3];
for(int j=0;j<N;j++){
tr[j] = comb[j];
}
for(int j=0;j<N;j++){
if(tr[j] == -1) tr[j] = 0;
}
int cor;
int c = tryCombination(tr);
if(c>i || c==-1) cor = 0;
else cor = 1;
int lo = 0;
int hi = N-1;
int ans = -1;
while(lo<=hi){
int X = (lo+hi)/2;
for(int j=lo;j<=X;j++){
if(comb[j] == -1) tr[j] = cor;
else tr[j] = comb[j];
}
for(int j=X+1;j<N;j++){
if(comb[j] == -1) tr[j] = 1-cor;
else tr[j] = comb[j];
}
int hehehehaw = tryCombination(tr);
if(hehehehaw>i ||hehehehaw == -1){
hi = X-1;
ans = X;
}
else lo = X+1;
}
link[ans] = i;
comb[ans] = cor;
}
answer(comb, link);
}
/*
main(){
exploreCave(4);
}
*/
# | 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... |