Submission #160557

# Submission time Handle Problem Language Result Execution time Memory
160557 2019-10-28T13:26:23 Z nvmdava Secret (JOI14_secret) C++17
Compilation error
0 ms 0 KB
#include "secret.h"
#include <bits/stdc++.h>

int val[1005][1005];
int a[1005];

void get(int l, int r){
    if(l > r)
        return;
    if(l == r){
        val[i][i] = a[i];
        return;
    }

    int m1 = (l + r) >> 1;
    int m2 = m1 + 1;

    val[m1][m1] = a[m1];
    val[m2][m2] = a[m2];

    for(int i = m1 - 1; i >= l; i--){
        val[i][m1] = val[m1][i] = Secret(val[i + 1][m1], a[i]);
    }
    for(int i = m2 + 1; i <= r; i++){
        val[i][m2] = val[m2][i] = Secret(val[i - 1][m2], a[i]);
    }

    get(l, m1 - 1);
    get(m2 + 1, r);
}

void Init(int N, int A[]){

    memset(val, -1, sizeof val);

    for(int i = 0; i < N; i++)
        a[i] = A[i];

    get(0, 1000);

}

int Query(int L, int R) {
    if(val[L][R])
        return val[L][R];
    for(int i = L; i < R; i++){
        if(val[L][i] != -1 && val[i + 1][R] != -1)
            return Secret(val[L][i], val[i + 1][R]);
    }
}

Compilation message

secret.cpp: In function 'void get(int, int)':
secret.cpp:11:13: error: 'i' was not declared in this scope
         val[i][i] = a[i];
             ^
secret.cpp: In function 'int Query(int, int)':
secret.cpp:50:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^