답안 #217616

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
217616 2020-03-30T11:05:07 Z DodgeBallMan 비밀 (JOI14_secret) C++14
0 / 100
506 ms 8420 KB
#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 ) {
    if( l == r ) return ;
    int mid = l + r >> 1;
    for( int i = mid - 1 ; i >= l ; i-- ) pre[i][mid] = Secret( pre[i+1][mid], a[i] );
    for( int i = mid + 2 ; i <= r ; i++ ) pre[mid+1][i] = Secret( pre[mid+1][i-1], a[i] );
    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();
}

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

secret.cpp: In function 'void solve(int, int)':
secret.cpp:12:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
     int mid = l + r >> 1;
               ~~^~~
secret.cpp: In function 'int Query(int, int)':
secret.cpp:29:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 137 ms 6392 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 840375341.
2 Incorrect 138 ms 6392 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 747241792.
3 Incorrect 140 ms 6392 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 688130334.
4 Incorrect 500 ms 8420 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 560152598.
5 Incorrect 503 ms 8312 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 497583184.
6 Incorrect 506 ms 8360 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 722663411.
7 Incorrect 506 ms 8312 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 657493000.
8 Incorrect 498 ms 8356 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 764569728.
9 Incorrect 505 ms 8388 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 277877441.
10 Incorrect 499 ms 8312 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 69725386.