# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
321491 | CaroLinda | Secret (JOI14_secret) | C++14 | 916 ms | 5188 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 "secret.h"
#include <bits/stdc++.h>
using namespace std ;
map< pair<int,int> , long long > mp ;
void divideConquer(int l, int r )
{
if( r-l+1 < 2 ) return ;
int mid = (r+l)>>1 ;
for(int i = mid+2 ; i <= r ; i++ )
mp[ make_pair(mid+1,i) ] = Secret(mp[make_pair(mid+1,i-1)], mp[ make_pair(i,i) ] ) ;
for(int i = mid-1 ; i >= l ; i-- )
mp[ make_pair(i,mid) ] = Secret(mp[ make_pair(i,i) ],mp[make_pair(i+1,mid)] ) ;
divideConquer(l, mid-1) ;
divideConquer(mid+2, r) ;
}
void Init(int N, int A[])
{
for(int i = 0 ; i < N ; i++ ) mp[ make_pair(i,i) ] = A[i] ;
divideConquer(0, N-1 ) ;
}
int Query(int L, int R)
{
for(int i= L ; i < R ; i++ )
{
auto lef = mp.find(make_pair(L,i) ) ;
auto rig = mp.find(make_pair(i+1, R) ) ;
if(lef == mp.end() || rig == mp.end() ) continue ;
return Secret( lef->second , rig->second ) ;
}
if( L == R ) return mp[ make_pair(L,L) ] ;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |