# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
831092 | starchan | Secret (JOI14_secret) | C++17 | 387 ms | 8200 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;
#define in pair<int, int>
#define f first
#define s second
#define pb push_back
#define pob pop_back
#define INF (int)1e17
#define MX (int)1e3+5
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
int XXX;
int table[MX][MX];
void build(const int a[], int l, int r)
{
int m = (l+r)/2;
if(l == r)
{
table[m][m] = a[m];
return;
}
table[m][m] = a[m];
for(int i = m-1; i >= l; i--)
table[i][m] = Secret(a[i], table[i+1][m]);
table[m+1][m+1] = a[m+1];
for(int i = m+2; i <= r; i++)
table[m+1][i] = Secret(table[m+1][i-1], a[i]);
build(a, l, m);
build(a, m+1, r);
return;
}
int query(int ql, int qr, int l, int r)
{
if(ql == qr)
return table[ql][qr];
int m = (l+r)/2;
if(ql == (m+1))
return table[m+1][qr];
else if(qr == m)
return table[ql][m];
if(qr < m)
return query(ql, qr, l, m);
else if(ql >= (m+2))
return query(ql, qr, m+1, r);
else
return Secret(table[ql][m], table[m+1][qr]);
}
void Init(int n, int a[])
{
build(a, 0, n-1);
XXX = n;
return;
}
int Query(int l, int r)
{
return query(l, r, 0, XXX-1);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |