Submission #53159

# Submission time Handle Problem Language Result Execution time Memory
53159 2018-06-28T21:42:35 Z okaybody10 Secret (JOI14_secret) C++
Compilation error
0 ms 0 KB
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
 
const int MX=1001, B=21;
 
int n, B[MX];
 
int D[MX][MX];
 
void _fill(int s=0, int e=n-1){
    int m=(s+e)/2;
    if(s==e){
        D[m][m]=A[m];
        return;
    }
    D[m][m]=A[m];
    for(int x=m-1; x>=s; x--){
        D[x][m]=Secret(A[x], D[x+1][m]);
    }
    D[m+1][m+1]=A[m+1];
    for(int y=m+2; y<=e; y++)
        D[m+1][y]=Secret(D[m+1][y-1], A[y]);
    _fill(s,m);
    _fill(m+1,e);
}
 
void Init(int N, int A[]) {
    n=N;
    for(int i=0; i<n; i++) B[i]=A[i];
    _fill();
}
int solve(int l, int r, int s=0, int e=n-1){
    int m=(s+e)/2;
    if(l<=m && m+1<=r){
        return Secret(D[l][m], D[m+1][r]);
    }
    if(r<=m) return solve(l,r,s,m);
    else return solve(l,r,m+1,e);
}
 
int Query(int l, int r) {
    if(l==r) return B[l];
    return solve(l,r);
}

Compilation message

secret.cpp:7:12: error: conflicting declaration 'int B [1001]'
 int n, B[MX];
            ^
secret.cpp:5:20: note: previous declaration as 'const int B'
 const int MX=1001, B=21;
                    ^
secret.cpp: In function 'void _fill(int, int)':
secret.cpp:14:17: error: 'A' was not declared in this scope
         D[m][m]=A[m];
                 ^
secret.cpp:17:13: error: 'A' was not declared in this scope
     D[m][m]=A[m];
             ^
secret.cpp: In function 'void Init(int, int*)':
secret.cpp:30:31: error: invalid types 'const int[int]' for array subscript
     for(int i=0; i<n; i++) B[i]=A[i];
                               ^
secret.cpp: In function 'int Query(int, int)':
secret.cpp:43:24: error: invalid types 'const int[int]' for array subscript
     if(l==r) return B[l];
                        ^