#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
inline namespace ns
{
template <typename T, typename Op>
struct SRQ
{
explicit SRQ(const vector<T> &vec, Op _op = Op())
: n((int)vec.size()), table(__lg(n) + 1, vector<T>(n)), op(_op)
{
table[0] = vec;
for (int x = 1; x < (int)table.size(); x++)
{
int j = 1 << x;
for (int i = j; i < n; i += j << 1)
{
table[x][i - 1] = vec[i - 1];
for (int l = i - 2, r = i - j; l >= r; l--)
table[x][l] = op(vec[l], table[x][l + 1]);
table[x][i] = vec[i];
for (int l = i + 1, r = min(n, i + j); l < r; l++)
table[x][l] = op(table[x][l - 1], vec[l]);
}
}
}
T query(int l, int r) const
{
assert(l < r);
--r;
if (l == r)
return table[0][l];
int x = __lg(l ^ r);
return op(table[x][l], table[x][r]);
}
private:
int n;
vector<vector<T>> table;
Op op;
};
} // namespace ns
namespace
{
SRQ<int, decltype(&Secret)> *srq;
}
void Init(int N, int A[])
{
static SRQ _srq(vector(A, A + N), Secret);
srq = &_srq;
}
int Query(int L, int R) { return srq->query(L, R + 1); }
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
122 ms |
2288 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
125 ms |
2292 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
145 ms |
2328 KB |
Output is correct - number of calls to Secret by Init = 4097, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
434 ms |
4428 KB |
Output is correct - number of calls to Secret by Init = 7979, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
444 ms |
4320 KB |
Output is correct - number of calls to Secret by Init = 7986, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
430 ms |
4304 KB |
Output is correct - number of calls to Secret by Init = 7986, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
440 ms |
4492 KB |
Output is correct - number of calls to Secret by Init = 7986, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
442 ms |
4308 KB |
Output is correct - number of calls to Secret by Init = 7986, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
456 ms |
4472 KB |
Output is correct - number of calls to Secret by Init = 7986, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
442 ms |
4300 KB |
Output is correct - number of calls to Secret by Init = 7986, maximum number of calls to Secret by Query = 1 |