#include <bits/stdc++.h>
#include "secret.h"
using namespace std;
#define ll long long
#define endl "\n"
#define INF 1000000000
#define LINF 1000000000000000LL
#define pb push_back
#define all(x) x.begin(), x.end()
#define len(s) (int)s.size()
#define test_case { int t; cin>>t; while(t--)solve(); }
#define single_case solve();
#define line cerr<<"----------"<<endl;
#define ios { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL); }
#define mod 1000000007LL
const int N = 1005;
int a[N][N];
int arr[N];
int n;
void build(int l, int r)
{
if(l==r||l==(r-1)||l>r) return;
int mid = (l+r)/2;
int val = arr[mid];
for(int i = mid-1;i>=l;i--)
{
val = Secret(arr[i], val);
a[i][mid] = val;
}
val = arr[mid+1];
for(int i = mid+2;i<=r;i++)
{
val = Secret(val, arr[i]);
a[mid+1][i] = val;
}
build(l, mid);
build(mid+1, r);
}
void Init(int N, int w[])
{
n = N;
for(int i = 0;i<n;i++) arr[i] = w[i];
for(int i = 0;i<n;i++) a[i][i] = arr[i];
build(0, n-1);
}
int resi(int l, int r, int i, int j)
{
int mid = (i+j)/2;
if(l<=mid&&r>mid)
{
return Secret(a[l][mid], a[mid+1][r]);
}
if(r==mid) return a[l][mid];
if(l==mid+1) return a[mid+1][r];
if(l>mid) return resi(l, r, mid+1, j);
else return resi(l, r, i, mid);
}
int Query(int l, int r)
{
if(l==r) return arr[l];
if(l==(r-1)) return Secret(arr[l], arr[r]);
return resi(l, r, 0, n-1);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
144 ms |
4480 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
143 ms |
4460 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
142 ms |
4460 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
504 ms |
8320 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
529 ms |
8248 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
502 ms |
8428 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
505 ms |
8300 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
519 ms |
8292 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
514 ms |
8300 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
528 ms |
8556 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |