Submission #671231

# Submission time Handle Problem Language Result Execution time Memory
671231 2022-12-12T12:53:25 Z Denkata Secret (JOI14_secret) C++17
100 / 100
429 ms 8240 KB
#include "secret.h"
int prefix[1006][1006];
int n;
void precompute(int l,int r,int A[])
{
    int mid = (l+r)/2;
    prefix[mid][mid]=A[mid];
    prefix[mid+1][mid+1]=A[mid+1];
    for(int i=mid+2;i<=r;i++)
        prefix[mid+1][i] = Secret(prefix[mid+1][i-1],A[i]);
    for(int i=mid-1;i>=l;i--)
        prefix[mid][i] = Secret(A[i],prefix[mid][i+1]);//reda ima znachenie - bqha naobratno parametrite
    if(mid+1<r)
        precompute(mid+1,r,A);
   if(mid>l)
        precompute(l,mid,A);
}
void Init(int N, int A[])
{
    n=N;
    precompute(0,N-1,A);
}
 
int Query(int L, int R)
{
    int l = 0, r = n-1;
    while(l!=r)
    {
        int mid = (l+r)/2;
        if(mid>=L && mid+1<=R)
            return Secret(prefix[mid][L],prefix[mid+1][R]);
        else if(mid==R)
            return prefix[mid][L];
        else if(mid<L)
            l=mid+1;
        else r=mid;
    }
    return prefix[l][l];
}
# Verdict Execution time Memory Grader output
1 Correct 118 ms 4328 KB Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1
2 Correct 121 ms 4380 KB Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1
3 Correct 122 ms 4300 KB Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1
4 Correct 422 ms 8140 KB Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1
5 Correct 423 ms 8188 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
6 Correct 417 ms 8140 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
7 Correct 425 ms 8200 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 421 ms 8208 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 424 ms 8240 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 429 ms 8212 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1