#include <bits/stdc++.h>
#include <secret.h>
#define tt cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(0)
#define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout)
#define ll long long
#define ull unsigned long long
#define i128 __int128
#define db long double
#define sz(a) ((int)(a).size())
#define pb emplace_back
#define pf emplace_front
#define pob pop_back
#define pof pop_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define ins emplace
using namespace std;
const int MOD = 1e9+7, MAXN = 1e5+5;
const string NAME = "";
pair<ll,bool> val[1005][1005];
void preprocess(int l, int r, int a[]){
if(l==r) return;
int mid=(l+r)>>1;
preprocess(l,mid,a);
preprocess(mid+1,r,a);
for(int i = mid-1; i>=l; --i)
if(!val[i][mid].se) val[i][mid].fi=Secret(a[i],val[i+1][mid].fi), val[i][mid].se=1;
for(int i = mid+2; i<=r; ++i)
if(!val[mid+1][i].se) val[mid+1][i].fi=Secret(val[mid+1][i-1].fi,a[i]), val[mid+1][i].se=1;
}
void Init(int n, int a[]){
for(int i = 0; i<n; ++i)
val[i][i].fi=a[i], val[i][i].se=1;
preprocess(0,n-1,a);
}
int Query(int l, int r){
if(val[l][r].se) return val[l][r].fi;
for(int i = l; i<r; ++i)
if(val[l][i].se&&val[i+1][r].se) return Secret(val[l][i].fi,val[i+1][r].fi);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
84 ms |
12872 KB |
Output is correct - number of calls to Secret by Init = 3084, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
90 ms |
12916 KB |
Output is correct - number of calls to Secret by Init = 3092, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
88 ms |
12872 KB |
Output is correct - number of calls to Secret by Init = 3101, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
307 ms |
19304 KB |
Output is correct - number of calls to Secret by Init = 6989, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
301 ms |
19272 KB |
Output is correct - number of calls to Secret by Init = 6997, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
311 ms |
19128 KB |
Output is correct - number of calls to Secret by Init = 6997, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
316 ms |
19272 KB |
Output is correct - number of calls to Secret by Init = 6997, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
306 ms |
19308 KB |
Output is correct - number of calls to Secret by Init = 6997, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
311 ms |
19300 KB |
Output is correct - number of calls to Secret by Init = 6997, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
306 ms |
19292 KB |
Output is correct - number of calls to Secret by Init = 6997, maximum number of calls to Secret by Query = 1 |