#include "secret.h"
#include<bits/stdc++.h>
using namespace std;
long n;
long u;
long a[130000];
map<pair<long,long>,long>m;
void build(long v,long tl,long tr)
{
if(tl==tr)
{
return ;
}
long tm=(tl+tr)/2;
long ans=a[tm];
for(long i=tm-1;i>=tl;i++)
{
ans=Secret(ans,a[i]);
m[{i,tm}]=ans;
}
ans=a[tm+1];
for(long i=tm+2;i<=tr;i++)
{
ans=Secret(ans,a[i]);
m[{tm+1,i}]=ans;
}
build(v*2,tl,tm);
build(v*2+1,tm+1,tr);
}
long get(long v,long tl,long tr,long l,long r)
{
long tm=(tl+tr)/2;
if(r<=tm)
{
return get(v*2,tl,tm,l,r);
}
if(l>tm)
{
return get(v*2+1,tm+1,tr,l,r);
}
long ans=Secret(m[{l,tm}],m[{tm+1,r}]);
return ans;
}
void Init(int N, int A[]) {
n=N;
for(long i=0;i<N;i++)
{
a[i]=A[i+1];
m[{a[i],a[i]}]=a[i];
}
build(1,0,n-1);
}
int Query(int L, int R) {
if(L==R)
{
return a[L-1];
}
return get(1,0,n-1,L-1,R-1);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
194 ms |
10480 KB |
Wrong Answer [1] |
2 |
Incorrect |
203 ms |
10472 KB |
Wrong Answer [1] |
3 |
Incorrect |
191 ms |
10548 KB |
Wrong Answer [1] |
4 |
Incorrect |
534 ms |
12460 KB |
Wrong Answer [1] |
5 |
Incorrect |
527 ms |
12420 KB |
Wrong Answer [1] |
6 |
Incorrect |
524 ms |
12400 KB |
Wrong Answer [1] |
7 |
Incorrect |
548 ms |
12472 KB |
Wrong Answer [1] |
8 |
Incorrect |
516 ms |
12488 KB |
Wrong Answer [1] |
9 |
Incorrect |
531 ms |
12472 KB |
Wrong Answer [1] |
10 |
Incorrect |
563 ms |
12448 KB |
Wrong Answer [1] |