#include <bits/stdc++.h>
#include "secret.h"
// #pragma GCC optimize ("Ofast,unroll-loops")
// #pragma GCC target ("avx2")
using namespace std;
typedef long long ll;
typedef pair<int, int> pp;
#define er(args ...) cerr << __LINE__ << ": ", err(new istringstream(string(#args)), args), cerr << endl
#define per(i,r,l) for(int i = (r); i >= (l); i--)
#define rep(i,l,r) for(int i = (l); i < (r); i++)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define pb push_back
#define ss second
#define ff first
void err(istringstream *iss){}template<typename T,typename ...Args> void err(istringstream *iss,const T &_val, const Args&...args){string _name;*iss>>_name;if(_name.back()==',')_name.pop_back();cerr<<_name<<" = "<<_val<<", ",err(iss,args...);}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll mod = 1e9 + 7, maxn = 1e3 + 2, sq = 710, lg = 11, inf = ll(1e9) + 5;
ll pw(ll a,ll b,ll md=mod){if(!b)return 1;ll k=pw(a,b>>1ll);return k*k%md*(b&1ll?a:1)%md;}
int vl[maxn][maxn], t[maxn];
int Query(int L, int R){ L++, R++;
pp mx = {0, 0};
rep(i,L,R+1) mx = max(mx, {t[i], i});
int mid = mx.ss;
if(mid == R) return vl[mid][L];
return Secret(vl[mid][L], vl[mid][R]);
}
void Init(int N, int A[]){
rep(i,1,N+1) t[i] = __builtin_ctz(i);
rep(i,1,N+1){
vl[i][i] = A[i-1];
per(j,i-1,1){
if(t[j] > t[i]) break;
vl[i][j] = Secret(A[j-1], vl[i][j+1]);
}
vl[i][i+1] = A[i];
rep(j,i+2,N+1){
if(t[j] > t[i]) break;
vl[i][j] = Secret(vl[i][j-1], A[j-1]);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
126 ms |
4300 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
125 ms |
4272 KB |
Output is correct - number of calls to Secret by Init = 4097, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
131 ms |
4328 KB |
Output is correct - number of calls to Secret by Init = 4098, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
437 ms |
8232 KB |
Output is correct - number of calls to Secret by Init = 7986, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
452 ms |
8164 KB |
Output is correct - number of calls to Secret by Init = 7998, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
434 ms |
8180 KB |
Output is correct - number of calls to Secret by Init = 7998, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
457 ms |
8244 KB |
Output is correct - number of calls to Secret by Init = 7998, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
441 ms |
8212 KB |
Output is correct - number of calls to Secret by Init = 7998, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
459 ms |
8212 KB |
Output is correct - number of calls to Secret by Init = 7998, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
452 ms |
8448 KB |
Output is correct - number of calls to Secret by Init = 7998, maximum number of calls to Secret by Query = 1 |