Submission #662823

#TimeUsernameProblemLanguageResultExecution timeMemory
662823AlmaCave (IOI13_cave)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "cave.h"
using namespace std;

void exploreCave(int N) {
    memset(S, 0, sizeof S);
    memset(D, -1, sizeof D);

    for (int i = 0; i < N; i++) {

        for (int j = 0; j < N; j++) {
            if (D[j] != -1) {
                A[j] = S[D[j]];
            } else {
                A[j] = 1;
            }
        }

        int ret = tryCombination(A);
        int target;
        if (ret == i) {
            target = 0;
        } else {
            target = 1;
        } 

        int lo = 0, mid, res = -1, hi = N-1;
        while (lo <= hi) {

            mid = (lo+hi) / 2;
            for (int j = 0; j < N; j++) {
                if (D[j] != -1) continue;
                if (j < mid) {
                    A[j] = target;
                } else {
                    A[j] = 1 - target;
                }
            }

            ret = tryCombination(A);
            if (ret == i) {
                lo = mid+1;
            } else {
                res = mid;
                hi = mid-1;
            }
        }

        S[i] = target;
        D[i] = res;
    }

    answer(S, D);
}

Compilation message (stderr)

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:6:12: error: 'S' was not declared in this scope
    6 |     memset(S, 0, sizeof S);
      |            ^
cave.cpp:7:12: error: 'D' was not declared in this scope
    7 |     memset(D, -1, sizeof D);
      |            ^
cave.cpp:13:17: error: 'A' was not declared in this scope
   13 |                 A[j] = S[D[j]];
      |                 ^
cave.cpp:15:17: error: 'A' was not declared in this scope
   15 |                 A[j] = 1;
      |                 ^
cave.cpp:19:34: error: 'A' was not declared in this scope
   19 |         int ret = tryCombination(A);
      |                                  ^