답안 #217627

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
217627 2020-03-30T11:12:55 Z DodgeBallMan 비밀 (JOI14_secret) C++14
0 / 100
571 ms 4728 KB
#include <bits/stdc++.h>
#include "secret.h"
 
const int N = 1e3 + 10;
 
int n, a[N], prer[10][N], prel[10][N];
 
 
void solve( int l = 1, int r = n, int cnt = 1 ) {
    if( cnt > 8 || 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 = 1 ; i <= n ; i++ ) a[i] = A[i-1];
    solve();
}
 
int cal( int ll, int rr, int l = 1, int r = n, int cnt = 1 ) {
    if( rr == ll ) return a[ll];
    if( rr == ll + 1 ) return Secret( a[ll], a[rr] );
    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 ) { return cal( L+1, R+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:29:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
     int mid = l + r >> 1;
               ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 147 ms 2552 KB Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1
2 Correct 164 ms 2552 KB Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1
3 Correct 155 ms 2728 KB Output is correct - number of calls to Secret by Init = 3594, maximum number of calls to Secret by Query = 1
4 Incorrect 502 ms 4488 KB Wrong Answer: Query(334, 336) - expected : 757125453, actual : 536870912.
5 Incorrect 503 ms 4572 KB Wrong Answer: Query(291, 293) - expected : 410949874, actual : 536870912.
6 Incorrect 508 ms 4728 KB Wrong Answer: Query(747, 749) - expected : 244228265, actual : 536870912.
7 Correct 571 ms 4512 KB Output is correct - number of calls to Secret by Init = 7490, maximum number of calls to Secret by Query = 1
8 Correct 518 ms 4464 KB Output is correct - number of calls to Secret by Init = 7490, maximum number of calls to Secret by Query = 1
9 Correct 515 ms 4472 KB Output is correct - number of calls to Secret by Init = 7490, maximum number of calls to Secret by Query = 1
10 Correct 514 ms 4472 KB Output is correct - number of calls to Secret by Init = 7490, maximum number of calls to Secret by Query = 1