Submission #668037

#TimeUsernameProblemLanguageResultExecution timeMemory
668037finn__동굴 (IOI13_cave)C++17
25 / 100
754 ms460 KiB
#include <bits/stdc++.h>
#include "cave.h"
using namespace std;

void exploreCave(int n)
{
    int p[n];
    vector<int> x(n); // switches to be determined
    for (size_t i = 0; i < n; i++)
        x[i] = i;

    int comb[n];
    fill(comb, comb + n, 0);

    for (size_t i = 0; i < n; i++)
    {
        // First determine wheter the next switch must be on or off.
        for (size_t i = 0; i < n - i; i++)
            comb[x[i]] = 0;
        bool next_on = (tryCombination(comb) == i);

        size_t a = 0, b = n - i - 1;

        while (a < b)
        {
            size_t mid = (a + b) / 2;
            for (size_t j = 0; j <= mid; j++)
                comb[x[j]] = !next_on;

            if (tryCombination(comb) == i)
                b = mid;
            else
                a = mid + 1;

            for (size_t j = 0; j <= mid; j++)
                comb[x[j]] = next_on;
        }

        p[x[a]] = i;
        comb[x[a]] = next_on;
        x.erase(x.begin() + a);
    }

    answer(comb, p);
}

Compilation message (stderr)

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:9:26: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
    9 |     for (size_t i = 0; i < n; i++)
      |                        ~~^~~
cave.cpp:15:26: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   15 |     for (size_t i = 0; i < n; i++)
      |                        ~~^~~
cave.cpp:20:46: warning: comparison of integer expressions of different signedness: 'int' and 'size_t' {aka 'long unsigned int'} [-Wsign-compare]
   20 |         bool next_on = (tryCombination(comb) == i);
      |                         ~~~~~~~~~~~~~~~~~~~~~^~~~
cave.cpp:30:38: warning: comparison of integer expressions of different signedness: 'int' and 'size_t' {aka 'long unsigned int'} [-Wsign-compare]
   30 |             if (tryCombination(comb) == i)
      |                 ~~~~~~~~~~~~~~~~~~~~~^~~~
#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...