#include<bits/stdc++.h>
#include "secret.h"
#define pll pair<ll, ll>
#define fi first
#define se second
#define pb push_back
#define pii pair<ll, pll>
using namespace std;
using ll = long long;
const int N = 1e4+55;
const ll mod = 998244353;
const ll base = 350;
const ll cs = 331;
ll m, n, t, k, a[N], ans, tong, b[N], c[N], d[N], P[N][12];
vector<ll> adj[N], kq;
ll pw(ll k, ll n)
{
ll total = 1;
for(; n; n >>= 1)
{
if(n & 1)total = total * k % mod;
k = k * k % mod;
}
return total;
}
void build(int l, int r, int lv)
{
if(l == r)return;
ll mid = (l + r) / 2;
P[mid][lv] = b[mid];
P[mid+1][lv] = b[mid+1];
for(int i = mid-1; i >= l; i --)P[i][lv] = Secret(b[i], P[i+1][lv]);
for(int i = mid+2; i <= r; i ++)P[i][lv] = Secret(P[i-1][lv], b[i]);
for(int i = mid+1; i <= r; i ++)a[i] |= (1<<lv);
build(l, mid, lv+1);
build(mid+1, r, lv+1);
}
void Init(int n, int A[])
{
for(int i = 0; i < n; i ++)b[i] = A[i];
build(0, n-1, 0);
}
int Query(int L, int R)
{
if(L == R)return b[L];
int lv = __builtin_ctz(a[L]^a[R]);
return Secret(P[L][lv], P[R][lv]);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
148 ms |
2632 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
147 ms |
2652 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
147 ms |
2676 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
520 ms |
4620 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
517 ms |
4520 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
528 ms |
4504 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
519 ms |
4520 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
539 ms |
4676 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
515 ms |
4604 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
518 ms |
4548 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |