Submission #540766

# Submission time Handle Problem Language Result Execution time Memory
540766 2022-03-21T17:05:09 Z Hazem Secret (JOI14_secret) C++14
0 / 100
515 ms 8232 KB
#include "secret.h"
#include <bits/stdc++.h>

const int M = 1e3+10;

int a[M],n;
int ans[4*M][M];

void build(int v,int tl,int tr){

    if(tl==tr)
        return ;

    int mid = (tl+tr)/2;

    ans[v][mid] = a[mid];
    ans[v][mid+1] = a[mid+1];

    for(int i=mid+2;i<=tr;i++)
        ans[v][i] = Secret(ans[v][i-1],a[i]);

    for(int i=mid-1;i>=tl;i--)
        ans[v][i] = Secret(ans[v][i+1],a[i]);

    build(v*2,tl,mid);
    build(v*2+1,mid+1,tr);
}

int get(int v,int tl,int tr,int l,int r){

    int mid = (tl+tr)/2;
    if(mid>=l&&mid<=r)
        return Secret(ans[v][l],ans[v][r]);

    if(r<=mid)
        return get(v*2,tl,mid,l,r);
    else
        return get(v*2+1,mid+1,tr,l,r);
}


void Init(int N, int A[]) {

    for(int i=0;i<N;i++)
        a[i+1] = A[i];

    n = N;
    build(1,1,N);
}

int Query(int L, int R) {

    if(L==R)
        return a[L];

    return get(1,1,n,L+1,R+1);
}

# Verdict Execution time Memory Grader output
1 Incorrect 127 ms 4360 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 268854015.
2 Incorrect 134 ms 4300 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560.
3 Incorrect 133 ms 4316 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 353554500.
4 Incorrect 500 ms 8124 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 343081568.
5 Incorrect 460 ms 8232 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 957013316.
6 Incorrect 490 ms 8220 KB Wrong Answer: Query(915, 915) - expected : 282904741, actual : 579799611.
7 Incorrect 449 ms 8192 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 675449873.
8 Incorrect 479 ms 8232 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273091792.
9 Incorrect 515 ms 8208 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 827853577.
10 Incorrect 475 ms 8228 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 337854787.