# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
487242 | MohamedAliSaidane | Secret (JOI14_secret) | C++14 | 437 ms | 8676 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "secret.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<pld> vpd;
#define pb push_back
#define popb pop_back
#define all(v) (v).begin(),(v).end()
#define ff first
#define ss second
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
/////// SOLUTION \\\\\\\
const int MAX_N = 1111;
int a[1111];
int n;
int range[MAX_N][MAX_N];
void build(int l, int r)
{
if(r - l < 2)
return ;
int m = (l+r)/2;
for(int i = m-1; i >=l; i--)
{
if(range[i][m] != -1) continue;
range[i][m] = Secret(range[i][i],range[i+1][m]);
}
for(int i = m +2; i <=r; i ++)
{
if(range[m+1][i] != -1) continue;
range[m+1][i] = Secret(range[m+1][i-1],range[i][i]);
}
build(l,m-1);
build(m+1,r);
}
void Init(int N, int A[])
{
n = N;
for(int i= 0; i <n; i ++)
a[i] = A[i];
for(int i = 0; i <n; i ++)
for(int j= 0; j <n; j ++)
range[i][j] = -1;
for(int i= 0; i <n; i ++)
range[i][i] = a[i];
build(0,n-1);
}
int Query(int l, int r)
{
if(range[l][r] != -1) return range[l][r];
for(int i = l; i <r; i++)
{
if(range[l][i] != -1 && range[i+1][r] != -1)
return range[l][r]= Secret(range[l][i],range[i+1][r]);
}
}
/*int main()
{
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int tt;
while(tt--)
{
solve();
}
}*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |