# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1234169 | Ice_man | Secret (JOI14_secret) | C++20 | 0 ms | 0 KiB |
/**
____ ____ ____ __________________ ____ ____ ____
||I || ||c || ||e || || || ||M || ||a || ||n ||
||__|| ||__|| ||__|| ||________________|| ||__|| ||__|| ||__||
|/__\| |/__\| |/__\| |/________________\| |/__\| |/__\| |/__\|
*/
#include <iostream>
#include <chrono>
#define maxn 1005
#define maxlog 20
#define INF 1000000010
#define LINF 1000000000000000005
#define endl '\n'
#define PB push_back
#define X first
#define Y second
#define control cout<<"passed"<<endl;
#pragma GCC optimize("O3" , "Ofast" , "unroll-loops" , "fast-math")
#pragma GCC target("avx2")
using namespace std;
typedef unsigned long long ull;
typedef std::pair <int, int> pii;
typedef long long ll;
typedef std::pair <ll, ll> pll;
typedef std::pair <int, ll> pil;
typedef std::pair <ll, int> pli;
typedef long double ld;
std::chrono::high_resolution_clock::time_point startT, currT;
constexpr double TIME_MULT = 1;
double timePassed()
{
using namespace std::chrono;
currT = high_resolution_clock::now();
double time = duration_cast<duration<double>>(currT - startT).count();
return time * TIME_MULT;
}
int a[maxn];
std::pair <ll, bool> pre[maxn][maxn];
void dnc(int l, int r)
{
if(l == r)
return;
int mid = (l + r) / 2;
dnc(l, mid);
dnc(mid + 1, r);
for(int i = mid - 1; i >= l; i--)
if(pre[i][mid].Y == false)
{
pre[i][mid].X = Secret(a[i], pre[i + 1][mid].X);
pre[i][mid].Y = true;
}
for(int i = mid + 2; i <= r; i++)
if(pre[mid + 1][i].Y == false)
{
pre[mid + 1][i].X = Secret(pre[mid + 1][i - 1].X, a[i]);
pre[mid + 1][i].Y = true;
}
}
void Init(int n , int x[])
{
for(int i = 0; i < n; i++)
{
pre[i][i].X = x[i];
pre[i][i].Y = true;
a[i] = x[i];
}
dnc(0 , n - 1);
}
int Query(int l , int r)
{
if(pre[l][r].Y == true)
return pre[l][r].X;
for(int i = l; i < r; i++)
if(pre[l][i].Y == true && pre[i + 1][r].Y == true)
return Secret(pre[l][i].X , pre[i + 1][r].X);
}