//#include "secret.h"
#include <bits/stdc++.h>
void Init(int N, int A[]);
int Query(int L, int R);
int Secret(int X, int Y);
int tr[10][1010];
int a[1010];
int n;
void bin(int now,int s,int e){
int i,sum;
int mid=(s+e)/2;
for(i=mid,sum=a[mid];i<e;i++)
{
tr[now][i]=sum;
if(i+1<e)
sum=Secret(sum,a[i+1]);
}
for(i=mid-1,sum=a[mid-1];i>=s;i--)
{
tr[now][i]=sum;
if(i-1>=s)
sum=Secret(a[i-1],sum);
}
if(e<=s+2)
return;
bin(now+1,s,mid);
bin(now+1,mid,e);
}
void Init(int N,int A[]){
n=N;
for(int i=0;i<n;i++)
a[i]=A[i];
bin(1,0,n);
/*for(int i=1;i<=9;i++)
{
for(int j=0;j<N;j++)
{
printf("%d ",tr[i][j]);
}
puts("");
}*/
}
int bin2(int now,int s,int e,int l,int r){
int mid=(s+e)/2;
if(s>r||e<l) return -1;
if(l<=mid&&r>=mid)
{
if(l==mid) return tr[now][r-1];
if(r==mid) return tr[now][l];
return Secret(tr[now][l],tr[now][r-1]);
}
int temp1=bin2(now+1,s,mid,l,r);
int temp2=bin2(now+1,mid,e,l,r);
//printf("%d %d %d %d %d: %d\n",now,s,e,l,r,temp1==-1?temp2:temp1);
if(temp1==-1) return temp2;
return temp1;
}
int Query(int l,int r){
return bin2(1,0,n,l,r+1);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
171 ms |
2572 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
172 ms |
2580 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
172 ms |
2552 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Runtime error |
603 ms |
8720 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
5 |
Runtime error |
604 ms |
8724 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
6 |
Runtime error |
603 ms |
8668 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
7 |
Runtime error |
605 ms |
8640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
8 |
Runtime error |
615 ms |
8668 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
9 |
Runtime error |
607 ms |
8704 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
10 |
Runtime error |
614 ms |
8684 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |