Submission #1310739

#TimeUsernameProblemLanguageResultExecution timeMemory
1310739theiulius동굴 (IOI13_cave)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#include "cave.h"

void exploreCave(int N) {
    int n = N;
    vector<int> used(n, 0);   // which switches already fixed (mp in your code)
    int a[n] = {}, b[n] = {};

    for (int i = 0; i < n; ++i) {
        // set all unfixed switches to 0 and query to determine berk
        for (int j = 0; j < n; ++j) if (!used[j]) a[j] = 0;
        int x = tryCombination(a);
        int berk = (x > i || x == -1) ? 0 : 1;

        // build list of unused switches (indices)
        vector<int> unused;
        unused.reserve(n);
        for (int j = 0; j < n; ++j) if (!used[j]) unused.push_back(j);

        // binary search on positions inside `unused`
        int L = 0, R = (int)unused.size() - 1;
        int pos = -1;
        while (L <= R) {
            int mid = (L + R) >> 1;

            // set first mid+1 unused switches to berk, rest to 1^berk
            for (int k = 0; k <= mid; ++k) a[unused[k]] = berk;
            for (int k = mid + 1; k < (int)unused.size(); ++k) a[unused[k]] = (1 ^ berk);

            x = tryCombination(a);
            if (x > i || x == -1) {
                pos = mid;      // possible answer in unused[pos]
                R = mid - 1;
            } else {
                L = mid + 1;
            }
        }

        // pos must be valid; but just in case (defensive), handle -1
        if (pos == -1) pos = (int)unused.size() - 1;

        int ans = unused[pos];
        b[ans] = i;
        used[ans] = 1;
        a[ans] = berk;    // fix this switch permanently
    }

    answer(a.data(), b.data());
}

Compilation message (stderr)

cave.cpp: In function 'void exploreCave(long long int)':
cave.cpp:50:14: error: request for member 'data' in 'a', which is of non-class type 'long long int [n]'
   50 |     answer(a.data(), b.data());
      |              ^~~~
cave.cpp:50:24: error: request for member 'data' in 'b', which is of non-class type 'long long int [n]'
   50 |     answer(a.data(), b.data());
      |                        ^~~~