Submission #217622

#TimeUsernameProblemLanguageResultExecution timeMemory
217622DodgeBallManSecret (JOI14_secret)C++14
0 / 100
509 ms8568 KiB
#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, int r ) { if( l == r ) return ; int mid = ( l + r ) / 2; for( int i = mid - 1 ; i >= l ; i-- ) pre[i][mid] = Secret( a[i], pre[i+1][mid] ); for( int i = mid + 2 ; i <= r ; i++ ) pre[mid+1][i] = Secret( a[i], pre[mid+1][i-1] ); solve( l, mid ), solve( mid+1, r ); } void Init( int N, int A[] ) { n = N; memset( pre, -1, sizeof pre ); for( int i = 0 ; i < n ; i++ ) pre[i][i] = a[i] = A[i]; solve( 0, n-1 ); } int Query( int l, int r ) { if( pre[l][r] != -1 ) return pre[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 (stderr)

secret.cpp: In function 'int Query(int, int)':
secret.cpp:29:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
#Verdict Execution timeMemoryGrader output
Fetching results...