# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
410845 | AlexRex0 | Cave (IOI13_cave) | C++14 | 456 ms | 496 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"
#include<bits/stdc++.h>
using namespace std;
bool visitado[5002];
int posiciones[5002];
int S[5002];
int prueba(int ini, int n){
for(int i = 0; i < n; ++i){
if(!visitado[i]){
S[i] = 0;
}
}
if(tryCombination(S) != ini){
return 1;
}
return 2;
}
void bs(int tipo, int busco, int fin){
int medio, ini = 0, res = -1;
fin--;
for(int i = 0; i <= fin; ++i){
if(!visitado[i]){
if(tipo == 2){
S[i] = 1;
}else{
S[i] = 0;
}
}
}
while(ini < fin){
medio = (ini + fin) / 2;
for(int i = medio + 1; i <= fin; ++i){
if(!visitado[i]){
if(tipo == 1){
S[i] = 1;
}else{
S[i] = 0;
}
}
}
if(tryCombination(S) != busco){
fin = medio;
}else{
for(int i = medio + 1; i <= fin; ++i){
if(!visitado[i]){
if(tipo == 1){
S[i] = 0;
}else{
S[i] = 1;
}
}
}
ini = medio + 1;
}
}
visitado[ini] = true;
if(tipo == 1){
S[ini] = 0;
}else{
S[ini] = 1;
}
posiciones[ini] = busco;
}
void exploreCave(int N) {
for(int i = 0; i < N; ++i){
int aux = prueba(i, N);
bs(aux, i, N);
}
answer(S, posiciones);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |