#include <bits/stdc++.h>;
#include "secret.h"
using namespace std;
#define LL pos*2+1
#define RR pos*2+2
const int NN=1e3+3;
long long seg[NN*4],a[NN],n,l,r,ans[NN][NN];
void build (int st,int en,int pos)
{
if (st==en)
{
seg[pos]=a[st];
return;
}
int mid= (st+en)/2;
build(st,mid,LL);
build(mid+1,en,RR);
seg[pos]=Secret(seg[LL],seg[RR]);
}
int query(int st,int en,int pos)
{
if (st>=l&&en<=r)
return seg[pos];
int mid=(st+en)/2;
int p1=-1,p2=-1;
if (!(st>r||mid<l))
p1=query(st,mid,LL);
if (!(mid+1>r||en<l))
p2=query(mid+1,en,RR);
if (p1==-1)
return p2;
if (p2==-1)
return p1;
return Secret(p1,p2);
}
void Init(int N, int A[])
{
n=N;
for (int i=0;i<n;i++)
a[i]=A[i];
build(0,n-1,0);
for (int i=0;i<n;i++)
{
ans[i][i]=a[i];
for (int j=i+1;j<n;j++)
{
l=i;
r=j;
ans[i][j]=query(0,N-1,0);
}
}
}
int Query(int L, int R)
{
l=L;
r=R;
return ans[l][r];
}
/*
8
1 4 7 2 5 8 3 6
4
0 3
1 7
5 5
2 4
*/
Compilation message
secret.cpp:1:25: warning: extra tokens at end of #include directive
1 | #include <bits/stdc++.h>;
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
656 ms |
5624 KB |
Output isn't correct - number of calls to Secret by Init = 786930, maximum number of calls to Secret by Query = 0 |
2 |
Partially correct |
666 ms |
5624 KB |
Output isn't correct - number of calls to Secret by Init = 791808, maximum number of calls to Secret by Query = 0 |
3 |
Partially correct |
668 ms |
5496 KB |
Output isn't correct - number of calls to Secret by Init = 797197, maximum number of calls to Secret by Query = 0 |
4 |
Partially correct |
2805 ms |
11608 KB |
Output isn't correct - number of calls to Secret by Init = 3488395, maximum number of calls to Secret by Query = 0 |
5 |
Partially correct |
2793 ms |
11468 KB |
Output isn't correct - number of calls to Secret by Init = 3497316, maximum number of calls to Secret by Query = 0 |
6 |
Partially correct |
2829 ms |
11516 KB |
Output isn't correct - number of calls to Secret by Init = 3497316, maximum number of calls to Secret by Query = 0 |
7 |
Partially correct |
2816 ms |
11512 KB |
Output isn't correct - number of calls to Secret by Init = 3497316, maximum number of calls to Secret by Query = 0 |
8 |
Partially correct |
2837 ms |
11348 KB |
Output isn't correct - number of calls to Secret by Init = 3497316, maximum number of calls to Secret by Query = 0 |
9 |
Partially correct |
2815 ms |
11452 KB |
Output isn't correct - number of calls to Secret by Init = 3497316, maximum number of calls to Secret by Query = 0 |
10 |
Partially correct |
2808 ms |
11244 KB |
Output isn't correct - number of calls to Secret by Init = 3497316, maximum number of calls to Secret by Query = 0 |