답안 #966930

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
966930 2024-04-20T16:06:41 Z Perl32 비밀 (JOI14_secret) C++14
컴파일 오류
0 ms 0 KB
//I wrote this code 4 u <3
#include <bits/stdc++.h>
#include "secret.h"

using namespace std;
using ll = long long;

#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif

constexpr int lg = 11;
constexpr int maxN = 1001;
int dat[lg][maxN];
int a[maxN], msk[maxN];

void divi(int l, int r, int lvl) {
    if (l == r) return;
    int m = (l + r) >> 1;
    dat[lvl][m] = a[m];
    for (int i = m; i >= l; --i) dat[lvl][i] = Secret(a[i], dat[lvl][i + 1]);
    dat[lvl][m + 1] = a[m + 1];
    for (int i = m + 2; i <= r; ++i) dat[lvl][i] = Secret(dat[lvl][i - 1], a[i]);
    for (int i = m + 1; i <= r; ++i) msk[i] ^= 1 << lvl;
    divi(l, m, lvl + 1);
    divi(m + 1, r, lvl + 1);
}

void Init(int N, int A[]) {
    for (int i = 0; i < N; ++i) a[i] = A[i];
    divi(0, n - 1, 0);
}

int Query(int l, int r) {
    if(l == r) return a[l];
    int lvl = __builtin_ctz(msk[l] ^ msk[r]);
    return Secret(dat[lvl][l], dat[lvl][r]);
}

//signed main(int32_t argc, char *argv[]) {
//    ios_base::sync_with_stdio(false);
//    cin.tie(nullptr);
//
//}

/*

 */

Compilation message

secret.cpp: In function 'void Init(int, int*)':
secret.cpp:33:13: error: 'n' was not declared in this scope
   33 |     divi(0, n - 1, 0);
      |             ^