Submission #1231955

#TimeUsernameProblemLanguageResultExecution timeMemory
1231955badge881Cave (IOI13_cave)C++20
100 / 100
425 ms516 KiB
#include <bits/stdc++.h>
#include "cave.h"
using namespace std;

void exploreCave(int N)
{
    vector<int> S(N, 0), D(N, 0);
    vector<bool> known(N, false);
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
            if (!known[j])
                S[j] = 0;
        int res = tryCombination(S.data());
        bool valTry = (res == i ? 1 : 0);
        int left = 0, right = N, ans = -1;
        while (left < right - 1)
        {
            int mid = (left + right) / 2;
            for (int j = 0; j < N; j++)
            {
                if (!known[j])
                {
                    if (j < mid)
                        S[j] = valTry;
                    else
                        S[j] = valTry ^ 1;
                }
            }
            int res = tryCombination(S.data());
            if (res == i)
                ans = mid, left = mid;
            else
                right = mid;
        }
        known[left] = 1;
        S[left] = valTry;
        D[left] = i;
    }
    answer(S.data(), D.data());
    return;
}
#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...