#include <bits/stdc++.h>
#include "secret.h"
const int N = 1e3 + 10;
int n, a[N], pre[N][N];
//int Secret( int a, int b ) { return a + b; }
void solve( int l = 1, int r = n, int cnt = 1 ) {
if( cnt > 8 || l == r ) return ;
int mid = l + r >> 1;
for( int i = mid - 1 ; i >= l ; i-- ) pre[i][mid] = Secret( prel[i+1][mid], a[i] );
for( int i = mid + 2 ; i <= r ; i++ ) pre[mid+1][i] = Secret( prer[mid+1][i-1], a[i] );
solve( l, mid, cnt+1 ), solve( mid+1, r, cnt+1 );
}
void Init( int N, int A[] ) {
n = N;
memset( pre, -1, sizeof pre );
for( int i = 1 ; i <= n ; i++ ) pre[i][i] = a[i] = A[i-1];
solve();
}
int Query( int l, int r ) {
++l, ++r;
for( int i = l ; i < r ; i++ ) if( pre[l][i] != -1 && pre[i+1][r] != -1 ) return Secret( pre[l][i], pre[i+1][r] );
}
/*int main()
{
int n, x[N], q;
scanf("%d",&n);
for( int i = 0 ; i < n ; i++ ) scanf("%d",&x[i]);
Init( n, x );
scanf("%d",&q);
while( q-- ) {
int a, b;
scanf("%d %d",&a,&b);
printf("%d\n",Query( a, b ) );
}
}*/
Compilation message
secret.cpp: In function 'void solve(int, int, int)':
secret.cpp:12:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
int mid = l + r >> 1;
~~^~~
secret.cpp:13:65: error: 'prel' was not declared in this scope
for( int i = mid - 1 ; i >= l ; i-- ) pre[i][mid] = Secret( prel[i+1][mid], a[i] );
^~~~
secret.cpp:13:65: note: suggested alternative: 'pre'
for( int i = mid - 1 ; i >= l ; i-- ) pre[i][mid] = Secret( prel[i+1][mid], a[i] );
^~~~
pre
secret.cpp:14:67: error: 'prer' was not declared in this scope
for( int i = mid + 2 ; i <= r ; i++ ) pre[mid+1][i] = Secret( prer[mid+1][i-1], a[i] );
^~~~
secret.cpp:14:67: note: suggested alternative: 'pre'
for( int i = mid + 2 ; i <= r ; i++ ) pre[mid+1][i] = Secret( prer[mid+1][i-1], a[i] );
^~~~
pre
secret.cpp: In function 'int Query(int, int)':
secret.cpp:29:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^