Submission #1127738

#TimeUsernameProblemLanguageResultExecution timeMemory
1127738PakinDioxideCave (IOI13_cave)C++17
Compilation error
0 ms0 KiB
#include "cave.h"

void exploreCave(int n) {
    // // SUBTASK 1
    // int idx = 0, a[n] = {}, b[n];
    // for (int i = 0; i < n; i++) b[i] = i;
    // while ((idx = tryCombination(a)) != -1) {
    //     a[idx] = 1;
    // }
    // answer(a, b);
    
    // SUBTASK 2
    // int a[n] = {}, b[n] = {};
    // for (int i = 0; i < n; i++) {
    //     a[i] = 1;
    //     b[i] = tryCombination(a);
    //     a[i] = 0;
    // }
    // answer(a, b);

    // FULL
    int idx = 0, a[n] = {}, b[n] = {}, v[n] = {};
    idx = tryCombination(a);
    while (idx != -1) {
        for (int i = 0; i < n; i++) {
            if (v[i]) continue;
            a[i] = 1;
            int id = tryCombination(a);
            if (id == -1 || id > idx) {
                v[i] = 1;
                b[i] = idx+1;
                idx = id;
                break;
            } else if (id < idx) {
                v[i] = 1;
                a[i] = 0;
            } else a[i] = 0;
        }
    }
    for (int i = 0; i < n; i++) {
        if (b[i]) b[i]--;
        else {
            a[i] = abs(a[i]-1);
            b[i] = tryCombination(a);
            a[i] = abs(a[i]-1);
        }
    }
    answer(a, b);
}

Compilation message (stderr)

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:43:20: error: 'abs' was not declared in this scope
   43 |             a[i] = abs(a[i]-1);
      |                    ^~~