# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
488409 | AmirElarbi | Secret (JOI14_secret) | C++14 | 448 ms | 8424 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"
#define vi vector<int>
#define ve vector
#define ll long long
#define vf vector<float>
#define vll vector<pair<ll,ll>>
#define ii pair<int,int>
#define vvi vector<vi>
#define vii vector<ii>
#define gii greater<ii>
#define pb push_back
#define fi first
#define se second
#define INF 1e9
#define eps 1e-7
#define eps1 1e-25
#define optimise ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MAX_A 1e5+5
#define V 450
using namespace std;
const int MOD = 1e9+7;
const int nax = 2005;
int n;
vi s;
int t[nax][nax];
void solve(int l, int r){
int md = (l+r)/2;
t[md][md] = s[md];
t[md+1][md+1] = s[md+1];
for (int i = md+2; i <= r; i++)
t[md+1][i] = Secret(t[md+1][i-1],s[i]);
for (int i = md-1; i >= l; i--)
t[md][i] = Secret(s[i],t[md][i+1]);
if(l < md) solve(l,md);
if(md +1 < r) solve(md+1,r);
}
void Init(int N, int A[]){
n = N;
for (int i = 0; i < N; ++i)
{
s.pb(A[i]);
}
solve(0,n-1);
}
int Query(int L, int R){
int l = 0, r = n-1;
while(l != r){
int md = (l+r)/2;
if(md >= L && md < R)
return Secret(t[md][L], t[md+1][R]);
else if(md == R) return t[md][L];
else if(md < L)
l = md+1;
else
r = md;
}
return t[l][l];
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |