#include <vector>
#include "secret.h"
#include <assert.h>
#define N 1050
int n, *a;
std::vector<int> pre[N<<1], suf[N<<1];
void build(int v, int l, int r)
{
if (l == r)
{
pre[v] = suf[v] = {a[l]};
return;
}
int m=(l+r)/2, vl=v+1, vr=v+(m-l+1)*2;
suf[v].resize(m-l+1);
suf[v][m-l] = a[m];
for (int i = m-l-1, j = m - 1; j >= l; --j, --i)
suf[v][i] = Secret(a[j], suf[v][i+1]);
pre[v].resize(r-m);
pre[v][0] = a[m+1];
for (int i = 1; i < r-m; ++i)
pre[v][i] = Secret(pre[v][i-1], a[m+1+i]);
build(vl, l, m);
build(vr, m+1, r);
}
int qry(int v, int l, int r, int x, int y)
{
int m = (l+r)/2, vl=v+1, vr=v+(m-l+1)*2;
if (l == r) assert(y == l);
if (y == m) return suf[v][suf[v].size() - 1 - (y - x)];
if (x == m + 1) return pre[v][y - x];
if (l <= x && y <= m) return qry(vl, l, m, x, y);
if (m + 1 <= x && y <= r) return qry(vr, m+1, r, x, y);
return Secret(qry(vl, l, m, x, y), qry(vr, m+1, r, x, y));
}
void Init(int n_, int *a_)
{
n = n_, a = a_;
build(0, 0, n-1);
}
int Query(int l, int r)
{
return qry(0, 0, n-1, l, r);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
105 ms |
7236 KB |
Execution killed with signal 6 |
2 |
Runtime error |
103 ms |
7248 KB |
Execution killed with signal 6 |
3 |
Runtime error |
101 ms |
7116 KB |
Execution killed with signal 6 |
4 |
Runtime error |
369 ms |
9216 KB |
Execution killed with signal 6 |
5 |
Runtime error |
372 ms |
8924 KB |
Execution killed with signal 6 |
6 |
Runtime error |
373 ms |
9012 KB |
Execution killed with signal 6 |
7 |
Runtime error |
371 ms |
9008 KB |
Execution killed with signal 6 |
8 |
Runtime error |
375 ms |
9028 KB |
Execution killed with signal 6 |
9 |
Runtime error |
372 ms |
9028 KB |
Execution killed with signal 6 |
10 |
Runtime error |
371 ms |
9044 KB |
Execution killed with signal 6 |