Submission #720293

# Submission time Handle Problem Language Result Execution time Memory
720293 2023-04-07T21:41:11 Z swagchicken Secret (JOI14_secret) C++14
Compilation error
0 ms 0 KB
#include "secret.h"

int n;
int pre[1010][1010] = {};

void process(int L, int R, int A[]) {
    if(L == R) return;

    int m = (L + R)/2;

    pre[m][m] = A[m];
    pre[m+1][m+1] = A[m+1];
    curr = pre[m][m];
    for(int i = m-1; i >= l; i--) {
        pre[m][i] = Secret(A[i], curr);
    }
    curr = pre[m+1][m+1];
    for(int i = m+2; i <= r; i++) {
        pre[m][i] = Secret(curr, A[i]);
    }
    process(0, m, A);
    process(m+1, r, A);
}   

void Init(int N, int A[]) {
    n = N;
    process(0, N-1, A);
}

int Query(int L, int R) {

    int lo = 0, hi = n-1;

    while(lo < hi) {
        int mid = (lo + hi)/2;
        if(L <= mid && R >= mid + 1) {
            return Secret(pre[L][mid], pre[mid+1][R]);
        } else if(R == mid) {
            return pre[L][mid];
        }
        
        if(R < mid + 1) {
            hi = mid;
        } else {
            lo = mid + 1;
        }
    }

}

Compilation message

secret.cpp: In function 'void process(int, int, int*)':
secret.cpp:13:5: error: 'curr' was not declared in this scope
   13 |     curr = pre[m][m];
      |     ^~~~
secret.cpp:14:27: error: 'l' was not declared in this scope
   14 |     for(int i = m-1; i >= l; i--) {
      |                           ^
secret.cpp:18:27: error: 'r' was not declared in this scope
   18 |     for(int i = m+2; i <= r; i++) {
      |                           ^
secret.cpp:22:18: error: 'r' was not declared in this scope
   22 |     process(m+1, r, A);
      |                  ^
secret.cpp: In function 'int Query(int, int)':
secret.cpp:49:1: warning: control reaches end of non-void function [-Wreturn-type]
   49 | }
      | ^