Submission #992841

#TimeUsernameProblemLanguageResultExecution timeMemory
992841Muaath_5Cave (IOI13_cave)C++17
0 / 100
2044 ms348 KiB
#include "cave.h"
void exploreCave(int n) {
    int sure[n] = {}, correct[n] = {}, index[n] = {};
    for (int i = 0; i < n; i++) {
        int open = tryCombination(correct) == i;
        int l = 0, r = n-1;
        while (l < r) {
            const int mid = (l+r)/2;
            int cpy[n];
            for (int i = 0; i < n; i++)
                cpy[i] = correct[i];
            if (!open)
                for (int i = mid+1; i < n; i++)
                    if (!sure[i])				
                        cpy[i] = 1;
            else
                for (int i = 0; i <= mid; i++)
                    if (!sure[i])
                        cpy[i] = 1;
            
            if (tryCombination(cpy) == i)
                l = mid+1;
            else
                r = mid;
        } 
        index[l] = i, correct[l] = open, sure[l] = 1;
    }
    answer(correct, index);
}

Compilation message (stderr)

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:12:16: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
   12 |             if (!open)
      |                ^
#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...