Submission #105205

#TimeUsernameProblemLanguageResultExecution timeMemory
105205Kenzo_1114Cave (IOI13_cave)C++14
0 / 100
30 ms616 KiB
#include<bits/stdc++.h> #include"cave.h" #define debug(args...) //fprintf(stderr,args) using namespace std; const int MAXN=5010; int N,resp[MAXN],porta[MAXN],v[MAXN]; /* int tryCombination(int v[]) { for(int i=0;i<N;i++) printf("%d ",v[i]); printf("\n"); int a; scanf("%d",&a); return a; } */ void color(int i,int j,int v[]) { for(;i<=j;i++) v[i]^=1; } void respdireta(int v[]) { for(int i=0;i<N;i++) porta[i]=v[i]; for(int i=0;i<N;i++) { v[i]^=1; int bla=tryCombination(v); resp[i]=bla; v[i]^=1; } } void exploreCave(int N) { for(int i=0;i<N;i++) { int ini=0,fim=N-1; while(ini<fim) { int m=(ini==fim-1) ? ini : (ini+fim)/2; debug("ini = %d fim = %d m = %d\n",ini,fim,m); debug("Case 1 :\n"); int case1=tryCombination(v); color(ini,m,v); debug("\n"); debug("Case 2 : \n"); int case2=tryCombination(v); color(ini,m,v); debug("\n"); /* debug("Case 3 : \n"); int case3=tryCombination(v); color(ini,fim,v); debug("\n");*/ if(case1==-1){ respdireta(v); return; } if(case2==-1){ color(ini,m,v); respdireta(v); return; } if(case1>i) { if(case2>i) ini=m; else color(m+1,fim,v), fim=m-1; } else { if(case2>i) color(ini,m,v), fim=m; else ini=m+1; } } porta[i]=fim; resp[i]=v[fim]; } } /* int main () { scanf("%d",&N); exploreCave(N); for(int i=0;i<N;i++) printf("%d ",porta[i]); printf("\n"); for(int i=0;i<N;i++) printf("%d ",resp[i]); printf("\n"); }*/
#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...