Submission #1179029

#TimeUsernameProblemLanguageResultExecution timeMemory
1179029woohyun_jngLibrary (JOI18_library)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

const int MAX = 1001;

vector<int> ans;
bool chk[MAX];

int N;

int query(vector<int> &Q) {
    int cnt = accumulate(Q.begin(), Q.end(), 0);
    return cnt - Query(Q);
}

vector<int> gen(vector<int> &arr) {
    vector<int> res(N, 0);
    for (int i : arr)
        res[i] = 1;
    return res;
}

int get(int X, vector<int> arr) {
    int S = arr.size(), A, B;
    if (S == 1)
        return arr[0];

    vector<int> L, R;
    for (int i = 0; i < S / 2; i++)
        L.push_back(arr[i]);
    for (int i = S / 2; i < S; i++)
        R.push_back(arr[i]);

    A = query(L);
    L.push_back(X), B = query(L);

    if (B - A >= 1) {
        L.pop_back();
        return get(X, L);
    } else
        return get(X, R);
}

void Solve(int n) {
    N = n;
    vector<int> Q(N, 1);

    if (N == 1) {
        ans.push_back(1);
        Answer(ans);
        return;
    }

    for (int i = 0; i < N; i++) {
        Q[i] = 0;
        if (query(Q) == 1) {
            ans[0] = i, chk[i] = true;
            break;
        }
        Q[i] = 1;
    }

    for (int i = 1; i < N; i++) {
        Q.clear();
        for (int j = 0; j < N; j++) {
            if (chk[j] || j == i)
                continue;
            Q.push_back(j);
        }
        ans[i] = get(i, Q);
    }

    Answer(ans);
}

Compilation message (stderr)

library.cpp: In function 'int query(std::vector<int>&)':
library.cpp:13:18: error: 'Query' was not declared in this scope; did you mean 'query'?
   13 |     return cnt - Query(Q);
      |                  ^~~~~
      |                  query
library.cpp: In function 'void Solve(int)':
library.cpp:50:9: error: 'Answer' was not declared in this scope
   50 |         Answer(ans);
      |         ^~~~~~
library.cpp:73:5: error: 'Answer' was not declared in this scope
   73 |     Answer(ans);
      |     ^~~~~~