#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 long long 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 ;
dp[mid][lev] = a[mid] ;
for(ll i = mid - 1 ; i >= l ; i--){
dp[i][lev] = Secret(dp[i + 1][lev] , a[i]) ;
}
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]) ;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
117 ms |
15556 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 268854015. |
2 |
Incorrect |
119 ms |
15536 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560. |
3 |
Incorrect |
120 ms |
15664 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 353554500. |
4 |
Incorrect |
416 ms |
17604 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 343081568. |
5 |
Incorrect |
421 ms |
17596 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 957013316. |
6 |
Incorrect |
426 ms |
17552 KB |
Wrong Answer: Query(200, 208) - expected : 277813445, actual : 154975445. |
7 |
Incorrect |
429 ms |
17628 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 675449873. |
8 |
Incorrect |
450 ms |
17504 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273091792. |
9 |
Incorrect |
437 ms |
17492 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 827853577. |
10 |
Incorrect |
456 ms |
17532 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 337854787. |