Submission #1244754

#TimeUsernameProblemLanguageResultExecution timeMemory
1244754j_vdd16Mechanical Doll (IOI18_doll)C++20
Compilation error
0 ms0 KiB
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

#define loop(X, N) for (int X = 0; X < (N); X++)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;

// void answer(vi C, vi X, vi Y) {
//     cout << "S: " << X.size() << endl;

//     int m = C.size() - 1;
//     for (int i = 0; i <= m; i++) {
//         cout << i << " -> " << C[i] << endl;
//     }
//     for (int i = 0; i < X.size(); i++) {
//         cout << -i - 1 << " -x-> " << X[i] << endl;
//         cout << -i - 1 << " -Y-> " << Y[i] << endl;
//     }
// }

int rev(int n, int numBits) {
    int out = 0;
    for (int i = 0; i < numBits; i++) {
        if (n & (1 << i))
            out |= 1 << (numBits - 1 - i);
    }

    return out;
}

void create_circuit(int m, vi a) {
    vi c; //exits
    vi x, y;
    int s = 0;

    int n = a.size();
    vvi nextStates(m);
    for (int i = 0; i < n - 1; i++)
        nextStates[a[i]].push_back(a[i + 1] + 1);

    nextStates[a[n - 1]].push_back(0);

    c.push_back(a[0] + 1);
    for (int i = 0; i < m; i++) {
        int pow = 1;
        while (pow < nextStates[i].size())
            pow *= 2;

        if (pow == 1) {
            c.push_back(nextStates[i][0]);
            continue;
        }

        vi exits(pow);
        for (int j = 0; j < nextStates[i].size() - 1; j++)
            exits[rev(j, pow)] = nextStates[i][j];
        for (int j = nextStates[i].size(); j < pow - 1; j++)
            exits[rev(j, pow)] = -rev(j + 1, pow);
        exits[rev(pow - 1, pow)] = nextStates[i].back();

        for (int j = 1; j < pow / 2; j++) {
            x.push_back(-(s + 2 * j));
            y.push_back(-(s + 2 * j + 1));
        }
        for (int j = 0; j < pow / 2; j++) {
            x.push_back(exits[j * 2]);
            y.push_back(exits[j * 2 + 1]);
        }

        c.push_back(-s - 1);
        s += pow - 1;
    }

    answer(c, x, y);
}

// int main() {
//     create_circuit(2, {0, 1});

//     return 0;
// }

Compilation message (stderr)

doll.cpp: In function 'void create_circuit(int, vi)':
doll.cpp:81:5: error: 'answer' was not declared in this scope
   81 |     answer(c, x, y);
      |     ^~~~~~