답안 #217645

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
217645 2020-03-30T11:34:21 Z DodgeBallMan 비밀 (JOI14_secret) C++14
0 / 100
691 ms 4408 KB
#include <bits/stdc++.h>
#include "secret.h"
 
const int N = 1e3 + 10;
 
int n, a[N], prer[10][N], prel[10][N];
 
//int Secret( int a, int b ) { return a + 2*( b/2); }
void solve( int l, int r, int cnt ) {
    if( l == r ) return ;
    int mid = l + r >> 1;
    prer[cnt][mid+1] = a[mid+1];
    prel[cnt][mid] = a[mid];
    for( int i = mid - 1 ; i >= l ; i-- ) prel[cnt][i] = Secret( a[i], prel[cnt][i+1] );
    for( int i = mid + 2 ; i <= r ; i++ ) prer[cnt][i] = Secret( prer[cnt][i-1], a[i] );
    solve( l, mid, cnt+1 ), solve( mid+1, r, cnt+1 );
}
 
 
void Init( int N_, int A[] ) {
    n = N_;
    for( int i = 0 ; i < n ; i++ ) a[i] = A[i];
    solve( 0, n-1, 1 );
}
 
int cal( int ll, int rr, int l, int r, int cnt ) {
    int mid = l + r >> 1;
    if( ll <= mid && mid + 1 <= rr ) return Secret( prel[cnt][ll], prer[cnt][rr] );
    else if( rr <= mid ) return cal( ll, rr, l, mid, cnt + 1 );
    else return cal( ll, rr, mid + 1, r, cnt + 1 );
}
 
int Query( int L, int R ) { 
    if( L == R ) return a[L];
    else if( L + 1 == R ) return Secret( a[L+1], a[L] );
    return cal( L, R, 0, n-1, 1 ); 
}
 
/*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:11:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
     int mid = l + r >> 1;
               ~~^~~
secret.cpp: In function 'int cal(int, int, int, int, int)':
secret.cpp:27:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
     int mid = l + r >> 1;
               ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 172 ms 2416 KB Wrong Answer: Query(182, 183) - expected : 213483071, actual : 514471767.
2 Incorrect 150 ms 2536 KB Wrong Answer: Query(210, 211) - expected : 558550312, actual : 8644065.
3 Incorrect 145 ms 2424 KB Wrong Answer: Query(130, 131) - expected : 127065177, actual : 33627487.
4 Incorrect 569 ms 4392 KB Wrong Answer: Query(955, 956) - expected : 283256648, actual : 585250604.
5 Incorrect 616 ms 4396 KB Wrong Answer: Query(957, 957) - expected : 115761809, actual : 273581959.
6 Incorrect 522 ms 4324 KB Wrong Answer: Query(653, 654) - expected : 227441904, actual : 725765755.
7 Correct 572 ms 4348 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 530 ms 4368 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 543 ms 4344 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 691 ms 4408 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1