Submission #672613

#TimeUsernameProblemLanguageResultExecution timeMemory
672613paulo_arCave (IOI13_cave)C++14
0 / 100
244 ms396 KiB
#include <bits/stdc++.h> #include "cave.h" using namespace std; int s [5004]; int res [5004]; bool activos [5004]; int ans [5004]; int busqueda (bool esuno, int inde, int n){ int izq=0, der=n; int mitad; int master; while(izq<=der){ mitad=(izq+der)/2; if(esuno)master=0; else master=1; for(int i=0; i<=mitad; i++){ if(activos[i]){ s[i]=res[i-1]; } else{ s[i]=master; } } if(esuno)master=1; else master=0; for(int i=mitad+1; i<n; i++){ if(res[i]){ s[i]=res[i]; } else{ s[i]=master; } } if(tryCombination(s)>=inde){ der=mitad-1; } else { izq=mitad+1; } } return mitad; } void exploreCave(int N) { int ll; for(int i=1; i<=N; i++){ res[i]=false; } for(int j=1; j<=N; j++){ int master=1; for(int i=1; i<N; i++){ if(res[i]){ s[i-1]=res[i]; } else{ s[i-1]=master; } } ll=tryCombination(s); int des; int a; if(ll>=j or ll==-1){ des= busqueda(true,j,N-1); a=1; } else { des=busqueda(false,j,N-1); a=0; } activos [des]=true; res[des-1]=a; ans[j-1]=des; } answer(res, ans); // int tryCombination(int S[]); //void answer(int S[], int D[]); //void exploreCave(int N); }

Compilation message (stderr)

cave.cpp: In function 'int busqueda(bool, int, int)':
cave.cpp:47:12: warning: 'mitad' may be used uninitialized in this function [-Wmaybe-uninitialized]
   47 |     return mitad;
      |            ^~~~~
#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...