제출 #377106

#제출 시각아이디문제언어결과실행 시간메모리
377106kevinxiehk동굴 (IOI13_cave)C++17
25 / 100
832 ms748 KiB
#include<cave.h> #ifdef __cplusplus extern "C" { #endif int tryCombination(int S[]); void answer(int S[], int D[]); void exploreCave(int N); #ifdef __cplusplus } #endif // TODO: global variables can be declared here int open[5000],corr[5000],test[5000],cor[5000]; void exploreCave(int N) { for(int i=0;i<N;i++){ int l=0,r=N-1; for(int j=l;j<=r;j++)test[j]=0; for(int j=0;j<i;j++)test[corr[j]]=open[j]; int a=tryCombination(test); if(a==-1)a=N+1; if(a<=i){ open[i]=1; for(int j=l;j<=r;j++)test[j]=1; for(int j=0;j<i;j++)test[corr[j]]=open[j]; } else open[i]=0; while(l<r){ int mid=(l+r)/2+1; for(int j=mid;j<=r;j++)test[j]^=1; for(int j=0;j<i;j++)test[corr[j]]=open[j]; a=tryCombination(test); if(a==-1)a=N+1; if(a<=i){ for(int j=l;j<=r;j++)test[j]^=1; l=mid; } else{ r=mid-1; } } corr[i]=l; } for(int i=0;i<N;i++)cor[corr[i]]=i; answer(open,cor); // TODO: implementation }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...