Submission #507343

#TimeUsernameProblemLanguageResultExecution timeMemory
507343amukkalirCave (IOI13_cave)C++17
46 / 100
15 ms448 KiB
#include "cave.h"
#include <bits/stdc++.h> 
using namespace std; 

int ud[5005]; 

void exploreCave(int N) {
    int S[N], D[N]; 
    for(int i=0; i<N; i++){
        S[i] = 0; 
        D[i] = -1; 
    }

    int rep = tryCombination(S); 
 
    while(rep != -1) {
        for(int i=0; i<N; i++) { 
            if(ud[i]) continue; //alr asked
            ud[i] = true; 
            S[i] ^= 1; 
            int nrep = tryCombination(S); 
            if(nrep == -1) {
                rep = -1;  
                break; 
            }
            else if(nrep < rep) {
                S[i] ^= 1; 
                D[i] = nrep; 
            } else if(nrep > rep) {
                D[i] = rep; 
                rep = nrep; //rep is like the farthest we can go
            }
            else ud[i] = false; 
        } 
    }

    for(int i=0; i<N; i++) {
        if(D[i] == -1) {
            S[i] ^= 1; 
            D[i] = tryCombination(S); 
            S[i] ^= 1; 
        }
    }

    answer(S, D);
}
#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...