Submission #953688

# Submission time Handle Problem Language Result Execution time Memory
953688 2024-03-26T13:22:40 Z infrapolar Secret (JOI14_secret) C++17
Compilation error
0 ms 0 KB
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
struct sparse_table
{
    vector<int> data[10];
    sparse_table(){}
    sparse_table(int sz, int* arr){
        data[0] = vector(arr, arr+sz);
        int block_size = 2;
        int j = 1;
        while (block_size < sz){
            data[j].assign(sz, 0);
            for (int begin = 0; begin < sz; begin+=2*block_size)
            {
                int center = min(sz-1, begin+block_size-1);
                data[j][center] = arr[center];
                for (int i = center - 1; i >= 0; i--)
                {
                    data[j][i] = Secret(arr[i], data[j][i+1]);
                }
                if (center != sz - 1)
                    data[j][center+1] = arr[center+1];
                for (int i = center+2; i < min(center+block_size+1, sz); i++)
                {
                    data[j][i] = Secret(data[j][i-1], arr[i]);
                }
                
            }
            block_size *= 2;
            j++;
        }
    }
    int query(int l, int r){
        if (l == r)
            return data[0][l];
        int layer = bit_width((uint32_t)l ^ r)-1;
        return Secret(data[layer][l], data[layer][r]);
    }
};
sparse_table str;
void Init(int N, int A[]) {
    str = sparse_table(N, A);
}

int Query(int L, int R) {
    return str.query(L, R);
}

Compilation message

secret.cpp: In member function 'int sparse_table::query(int, int)':
secret.cpp:37:21: error: 'bit_width' was not declared in this scope
   37 |         int layer = bit_width((uint32_t)l ^ r)-1;
      |                     ^~~~~~~~~