#include "secret.h"
//apig's property
//Happiness can be found, even in the darkest of times, if one only remembers to turn on the light
//El Pueblo Unido Jamas Sera Vencido
//Do or do not... there is no try
//Billions of bilious blue blistering barnacles in a thundering typhoon!
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0)
#define F first
#define S second
#define pb push_back
#define vll vector< ll >
#define vi vector< int >
#define pll pair< ll , ll >
#define pi pair< int , int >
#define all(s) s.begin() , s.end()
#define sz(s) s.size()
#define str string
#define md ((s + e) / 2)
//#define mid ((l + r) / 2)
#define msdp(dp) memset(dp , -1 , sizeof dp)
#define mscl(dp) memset(dp , 0 , sizeof dp)
#define C continue
#define R return
#define B break
#define lx node * 2
#define rx node * 2 + 1
#define br(o) o ; break
#define co(o) o ; continue
using namespace std;
typedef int ll;
ll q, dp[300005][20] , a[555555] , mask[555555], k, l, m, n, o, p;
map < ll , ll > mp;
vll adj[555555];
const ll mod = 1e9+7;
str s;
void div(ll l , ll r , ll lev){
if(l == r)R ;
ll mid = (r + l) / 2 ;
dp[mid][lev] = a[mid] ;
for(ll i = mid - 1 ; i >= l ; i--){
dp[i][lev] = Secret(a[i] , dp[i + 1][lev]) ;
}
dp[mid + 1][lev] = a[mid + 1] ;
for(ll i = mid + 2 ; i <= r ; i++){
dp[i][lev] = Secret(dp[i - 1][lev] , a[i]) ;
}
for(ll i = mid + 1 ; i <= r ; i++)mask[i] ^= (1 << lev) ;
div(l , mid , lev + 1) , div(mid + 1 , r , lev + 1) ;
}
void Init(int N, int A[]) {
n = N ;
for(ll i = 0 ; i < n ; i++){
a[i] = A[i] ;
}
div(0 , n - 1 , 0) ;
}
int Query(int l, int r) {
if(l == r)R a[r] ;
ll bits = __builtin_ctz(mask[l] ^ mask[r]) ;
R Secret(dp[l][bits] , dp[r][bits]) ;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
125 ms |
15408 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
125 ms |
15428 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
130 ms |
15400 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
425 ms |
17344 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
433 ms |
17396 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
429 ms |
17316 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
437 ms |
17352 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
427 ms |
17412 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
438 ms |
17404 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
427 ms |
17412 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |