Submission #964749

#TimeUsernameProblemLanguageResultExecution timeMemory
964749vjudge1Cave (IOI13_cave)C11
100 / 100
699 ms808 KiB
#include "cave.h"

#define NN 5005

void exploreCave(int n) {
    static int s2d[NN], isknown[NN], correct[NN];
    for (int i = 0; i < n; ++i)
        isknown[i] = 0;

    for (int i = 0; i < n; ++i)
    {
        static int s[NN];

        for (int j = 0; j < n; ++j)
        {
            s[j] = 0;
            if (isknown[j])
                s[j] = correct[j];
        }

        int first, correct_;

        first = tryCombination(s);
        if (first == -1 || first > i)
            correct_ = 0;
        else 
            correct_ = 1;

        int lower = -1, upper = n;
        while (upper - lower > 1)
        {
            int mid = lower+(upper-lower)/2;
            for (int j = 0; j < n; ++j)
            {
                if (isknown[j])
                    continue;
                if (j <= mid)
                    s[j] = correct_;
                else
                    s[j] = correct_^1;
            }

            int first = tryCombination(s);
            if (first == -1 || first > i)
                upper = mid;
            else
                lower = mid;
        }

        int sw = upper;

        s2d[sw] = i;
        isknown[sw] = 1;
        //known[ko++] = sw;
        correct[sw] = correct_;
    }


    answer(correct, s2d);
    /* ... */
}

#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...