#include <bits/stdc++.h>
#define MAX 1005
#include "secret.h"
int array[MAX];
int n;
int left[MAX*4][MAX],right[MAX*4][MAX];
int resp=0;
void acessa(int l,int r,int la=0,int ra=n-1,int pos=1){
if(r<la||ra<l)return;
int m = (la+ra)/2;
if(l<=m&&r>=m){
int posl=l-la;
int posr=r-(m+1);
int esq=left[pos][posl];
if(posr>=0)esq=Secret(esq,right[pos][posr]);
resp=esq;
return;
}
acessa(l,r,la,m,pos*2);
acessa(l,r,m+1,ra,(pos*2)+1);
}
void prep(int la=0,int ra=n-1,int pos=1){
int m = (la+ra)/2;
{
int ado=array[m];
for(int i=m;i!=la-1;--i){
int cord = i-la;
if(i!=m){
ado=Secret(array[i],ado);
}
left[pos][cord]=ado;
}
}
{
int ado=array[m+1];
for(int i=m+1;i!=ra+1;++i){
int cord = i-(m+1);
if(i!=m+1){
ado=Secret(ado,array[i]);
}
right[pos][cord]=ado;
}
}
if(la==ra)return;
prep(la,m,pos*2);
prep(m+1,ra,(pos*2)+1);
}
void Init(int N, int A[]){
n=N;
for(int i=0;i!=N;++i)array[i]=A[i];
prep();
}
int Query(int L, int R){
acessa(L-1,R-1);
return resp;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
121 ms |
8436 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 22166791. |
2 |
Incorrect |
138 ms |
8416 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 306225408. |
3 |
Incorrect |
134 ms |
8448 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 629483540. |
4 |
Incorrect |
441 ms |
16120 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 34079308. |
5 |
Incorrect |
441 ms |
16076 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 542818560. |
6 |
Incorrect |
448 ms |
16132 KB |
Wrong Answer: Query(915, 915) - expected : 282904741, actual : 579799611. |
7 |
Incorrect |
455 ms |
16068 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 772352096. |
8 |
Incorrect |
466 ms |
16068 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 290455552. |
9 |
Incorrect |
446 ms |
16100 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 164632041. |
10 |
Incorrect |
455 ms |
16044 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 872638089. |