#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;
typedef long long ll;
#include "secret.h"
const int N = 1007;
int val[N][N];
int n;
void Init(int nn, int A[]) {
n = nn;
function <void(int, int)> rec = [&] (int l, int r) {
if (l > r) return;
int m = (l + r) >> 1;
rec(l, m - 1);
rec(m + 1, r);
val[m][m] = A[m];
for (int i = m - 1; i >= l; --i) {
val[m][i] = Secret(A[i], val[m][i + 1]);
}
if (m < r) {
val[m][m + 1] = A[m + 1];
for (int i = m + 2; i <= r; ++i) {
val[m][i] = Secret(val[m][i - 1], A[i]);
}
}
};
rec(0, n - 1);
}
int Query(int ql, int qr) {
function <int(int, int)> rec = [&] (int l, int r) {
int m = (l + r) >> 1;
if (ql <= m && m <= qr) {
int vl = val[m][ql];
if (qr != m) {
vl = Secret(vl, val[m][qr]);
}
return vl;
} else {
if (qr < m) {
return rec(l, m - 1);
} else {
return rec(m + 1, r);
}
}
};
return rec(0, n - 1);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
151 ms |
4600 KB |
Output is correct - number of calls to Secret by Init = 3331, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
144 ms |
4472 KB |
Output is correct - number of calls to Secret by Init = 3339, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
144 ms |
4448 KB |
Output is correct - number of calls to Secret by Init = 3347, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
512 ms |
8440 KB |
Output is correct - number of calls to Secret by Init = 7467, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
506 ms |
8420 KB |
Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
513 ms |
8404 KB |
Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
514 ms |
8440 KB |
Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
503 ms |
8184 KB |
Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
502 ms |
8292 KB |
Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
505 ms |
8440 KB |
Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1 |