# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1177626 | vnedu | Secret (JOI14_secret) | C++20 | 0 ms | 0 KiB |
#include "secret.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> bool maximize(T &a, const T &b){ return (a < b ? a = b, 1 : 0); }
template<class T> bool minimize(T &a, const T &b){ return (a > b ? a = b, 1 : 0); }
#define fi first
#define se second
#define pb push_back
#define ii pair<int, int>
#define all(x) x.begin(), x.end()
#define TASK "nonsense"
/// end of template ///
const int N = 1e3 + 13;
int n,a[N],dp[N][N];
void work(int l, int r)
{
if (l==r)
{
dp[l][r]=a[l];
return;
}
int mid((l+r)>>1);
work(l,mid);
work(mid+1,r);
for (int i=mid-1; i>=l; --i) dp[i][mid]=Secret(a[i],dp[i+1][mid]);
for (int i=mid+2; i<=r; ++i) dp[mid+1][i]=Secret(dp[mid+1][i-1],a[i]);
}
void Init(int N, int A[])
{
n=N;
for (int i=0; i<n; ++i) a[i+1]=A[i];
work(1,n);
}
int Query(int lo, int hi)
{
if (lo==hi) return a[lo];
int l=1,r=n,mid;
while (1)
{
mid=(lo+hi)>>1;
if (hi<=mid) r=mid;
else if (mid+1<=lo) l=mid+1;
else break;
}
mid=(l+r)>>1;
return Secret(dp[lo][mid],dp[mid+1][hi]);
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// freopen(TASK".inp","r",stdin);
// freopen(TASK".out","w",stdout);
int testcase=1;
// cin>>testcase;
while (testcase--)
solve();
// #define TIME (1.0 * clock() / CLOCKS_PER_SEC)
// cerr << "Time elapsed: " << TIME << " s.\n";
return 0;
}