# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
361534 | shahriarkhan | Secret (JOI14_secret) | C++14 | 511 ms | 4716 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#include "secret.h"
using namespace std ;
const int mx = 1024 ;
int pre[mx][mx] , a[mx] , n ;
void dnc(int l , int r , int d)
{
if(l+1==r) return ;
if(l==r) return ;
int mid = (l+r)>>1 ;
pre[d][mid] = a[mid] , pre[d][mid+1] = a[mid+1] ;
for(int i = mid - 1 ; i >= l ; --i)
{
pre[d][i] = Secret(pre[d][i+1],a[i]) ;
}
for(int i = mid + 2 ; i <= r ; ++i)
{
pre[d][i] = Secret(pre[d][i-1],a[i]) ;
}
dnc(l,mid,d+1) , dnc(mid+1,r,d+1) ;
}
void Init(int N , int A[])
{
n = N ;
for(int i = 0 ; i < N ; ++i) a[i] = A[i] ;
dnc(0,N-1,0) ;
}
int dq(int l , int r , int d , int ql , int qr)
{
int mid = (l+r)>>1 ;
if(ql<=mid && qr>mid) return Secret(pre[d][ql],pre[d][qr]) ;
if(qr==mid) return pre[d][ql] ;
if(qr<mid) return dq(l,mid,d+1,ql,qr) ;
else return dq(mid+1,r,d+1,ql,qr) ;
}
int Query(int L , int R)
{
if(L==R) return a[L] ;
if(L+1==R) return Secret(a[L],a[R]) ;
return dq(0,n-1,0,L,R) ;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |