#include "secret.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn=1000+10;
int n,all[maxn],dp[maxn][maxn];
int pors(int l,int r){
if(l==r){
return all[l];
}
return Secret(all[l],dp[l+1][r]);
}
int pors2(int l,int r){
if(l==r){
return all[l];
}
return Secret(dp[l][r-1],all[r]);
}
void create(int l,int r){
if(l>r){
return ;
}
int m=(l+r)>>1;
for(int i=m;i>=l;i--){
dp[i][m]=pors(i,m);
//cout<<i<<" "<<m<<" "<<dp[i][m]<<"\n";
}
for(int i=m+1;i<=r;i++){
dp[i][m]=pors2(m+1,i);
//cout<<i<<" "<<m<<" "<<dp[i][m]<<"\n";
}
create(m+1,r);
create(l,m-1);
}
void Init(int N, int A[]) {
n=N;
for(int i=0;i<n;i++){
all[i]=A[i];
}
create(0,n-1);
}
int solve(int l,int r,int tl=0,int tr=n-1){
int m=(tl+tr)/2;
if(l>m&&r>m){
return solve(l,r,m+1,tr);
}
if(l<m&&r<m){
return solve(l,r,l,m-1);
}
if(l==m){
return Secret(all[l],dp[r][m]);
}
if(r==m){
return dp[l][m];
}
//cout<<l<<" "<<m<<" "<<r<<" "<<dp[l][m]<<" "<<dp[r][m]<<"\n";
return Secret(dp[l][m],dp[r][m]);
}
int Query(int L, int R) {
if(L==R){
return all[L];
}
return solve(L,R);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
100 ms |
6824 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 536870912. |
2 |
Incorrect |
100 ms |
6740 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 38449312. |
3 |
Incorrect |
100 ms |
6836 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 696690974. |
4 |
Incorrect |
375 ms |
8276 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 536870912. |
5 |
Incorrect |
372 ms |
8276 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 874010704. |
6 |
Incorrect |
373 ms |
8272 KB |
Wrong Answer: Query(738, 741) - expected : 983692994, actual : 536870912. |
7 |
Incorrect |
400 ms |
8272 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 704129056. |
8 |
Incorrect |
372 ms |
8360 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 427077896. |
9 |
Incorrect |
378 ms |
8528 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 281940969. |
10 |
Incorrect |
373 ms |
8268 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 68832328. |