Submission #321491

#TimeUsernameProblemLanguageResultExecution timeMemory
321491CaroLindaSecret (JOI14_secret)C++14
100 / 100
916 ms5188 KiB
#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)

secret.cpp: In function 'int Query(int, int)':
secret.cpp:50:1: warning: control reaches end of non-void function [-Wreturn-type]
   50 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...