Submission #106341

#TimeUsernameProblemLanguageResultExecution timeMemory
106341Kenzo_1114Cave (IOI13_cave)C++14
51 / 100
2050 ms736 KiB
#include<bits/stdc++.h> #include"cave.h" #define debug(args...) //fprintf(stderr,args) using namespace std; const int MAXN=5010; set<int> s; 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++) { if(s.find(i)!=s.end()) continue; v[i]=0; } } void color2(int i,int j,int v[]) { for(;i<=j;i++) { if(s.find(i)!=s.end()) continue; v[i]=1; } } void exploreCave(int N) { for(int i=0;i<N;i++) { int ini=0,fim=N-1,type; color(ini,fim,v); int case1=tryCombination(v); if(case1==i) type=0; else{ color2(ini,fim,v); type=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"); debug("\n"); if(type==0) { color2(ini,m,v); int case2=tryCombination(v); if(case2>i || case2==-1){ color(ini,m,v); fim=m; } else ini=m+1; } else { color(ini,m,v); int case2=tryCombination(v); if(case2>i || case2==-1){ color2(ini,m,v); fim=m; } else ini=m+1; } } s.insert(ini); v[ini]^=1; porta[ini]=i; debug("I = %d v[%d] = %d\n",i,ini,v[ini]); } answer(v,porta); } /* int main () { scanf("%d",&N); exploreCave(N); for(int i=0;i<N;i++) printf("%d ",v[i]); printf("\n"); for(int i=0;i<N;i++) printf("%d ",porta[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...