#include <bits/stdc++.h>
#include "secret.h"
#define taskname "test"
#define fi first
#define se second
#define pb push_back
#define faster ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
using ll = long long;
using pii = pair <int, int>;
using pil = pair <int, ll>;
using pli = pair <ll, int>;
using pll = pair <ll, ll>;
using ull = unsigned ll;
mt19937 Rand(chrono::steady_clock::now().time_since_epoch().count());
ll min(const ll &a, const ll &b){
return (a < b) ? a : b;
}
ll max(const ll &a, const ll &b){
return (a > b) ? a : b;
}
//const ll Mod = 1000000009;
//const ll Mod2 = 999999999989;
//only use when required
const int maxN = 1e3 + 1;
int n;
int cal[maxN][maxN];
int aa[maxN];
int cnt = 0;
void prepare(int l = 0, int r = n - 1){
if (l > r) return;
int mid = (l + r) / 2;
cal[mid][mid] = aa[mid];
cal[mid + 1][mid + 1] = aa[mid + 1];
if (l + 1 >= r) return;
for (int i = mid - 1; i >= l; --i){
cal[mid][i] = Secret(aa[i], cal[mid][i + 1]);
}
for (int i = mid + 2; i <= r; ++i){
cal[mid + 1][i] = Secret(cal[mid + 1][i - 1], aa[i]);
}
prepare(l, mid - 1);
prepare(mid + 2, r);
}
int Query(int a, int b){
int l = 0, r = n - 1;
while (l < r){
int mid = (l + r) / 2;
if (a <= mid && mid + 1 <= b) return Secret(cal[mid][a], cal[mid + 1][b]);
if (mid == b) return cal[b][a];
if (mid + 1 == a) return cal[a][b];
if (b < mid) r = mid - 1;
if (a > mid + 1) l = mid + 2;
}
return cal[l][l];
}
void Init(int N, int A[]){
n = N;
for (int i = 0; i < n; ++i) aa[i] = A[i];
prepare();
//really? a star b != b star a?
}
/*
int main(){
if (fopen(taskname".inp", "r")){
freopen(taskname".inp", "r", stdin);
//freopen(taskname".out", "w", stdout);
}
faster;
ll tt = 1;
//cin >> tt;
while (tt--){
Init();
}
}*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
125 ms |
4604 KB |
Output is correct - number of calls to Secret by Init = 3084, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
122 ms |
4360 KB |
Output is correct - number of calls to Secret by Init = 3092, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
119 ms |
4384 KB |
Output is correct - number of calls to Secret by Init = 3100, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
438 ms |
8268 KB |
Output is correct - number of calls to Secret by Init = 6988, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
433 ms |
8152 KB |
Output is correct - number of calls to Secret by Init = 6996, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
434 ms |
8236 KB |
Output is correct - number of calls to Secret by Init = 6996, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
430 ms |
8144 KB |
Output is correct - number of calls to Secret by Init = 6996, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
428 ms |
8184 KB |
Output is correct - number of calls to Secret by Init = 6996, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
422 ms |
8180 KB |
Output is correct - number of calls to Secret by Init = 6996, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
426 ms |
8140 KB |
Output is correct - number of calls to Secret by Init = 6996, maximum number of calls to Secret by Query = 1 |