# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
285447 | Bill_00 | Cave (IOI13_cave) | C++14 | 0 ms | 0 KiB |
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"
int p[10000]={0},a[10000],up[10000];
void dfs(int l,int r,int L,int R,int id,int now){
for(int i=L;i<=R;i++){
if(p[i]!=0) continue;
a[i]+=1;
a[i]%=2;
}
int k=tryCombination(a);
if(L==R && k!=id && now==0){
p[L+1]=id;
up[L+1]=a[L+1];
return;
}
if(L==R && k==id && now==0){
p[L]=id;
up[L]=(a[L]+1)%2;
return;
}
if(L==R && k!=id && now==1){
p[L]=id;
up[L]=a[L];
return;
}
if(L==R && k==id && now==1){
p[L+1]=id;
up[L+1]=(a[L+1]+1)%2;
return;
}
if(k!=id && now==1){
dfs(L,R,L,(L+R)/2,id,0);
}
if(k!=id && now==0){
if(R+1==l){
p[l]=id;
up[l]=a[l];
return;
}
dfs(R+1,l,R+1,(l+R+1)/2,id,0);
}
if(k==id && now==1){
if(R+1==l){
p[l]=id;
up[l]=(a[l]+1)%2;
return;
}
dfs(R+1,l,R+1,(l+R+1)/2,id,1);
}
if(k==id && now==0){
dfs(L,R,L,(L+R)/2,id,1);
}
}
void exploreCave(int n) {
for(int i=0;i<n;i++){
a[i]=1;
}
for(int i=1;i<=n;i++){
int k=tryCombination(a);
if(k==id) dfs(0,n-1,0,(n-1)/2,i,1);
else dfs(0,n-1,0,(n-1)/2,i,0)
}
answer(up,p);
}