# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
556097 | urosk | Secret (JOI14_secret) | C++14 | 522 ms | 8348 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 "secret.h"
#define here cerr<<"===========================================\n"
#include <bits/stdc++.h>
#define ld double
#define ll long long
#define ull unsigned long long
#define llinf 100000000000000000LL // 10^17
#define iinf 2000000000 // 2*10^9
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define sz(a) int(a.size())
#define all(a) a.begin(),a.end()
#define ceri(a,l,r) {for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;}
using namespace std;
#define maxn 1005
int a[maxn];
int c[maxn][maxn];
int n;
void init(int l,int r){
if(l>=r) return;
int mid = (l+r)/2;
for(int i = mid+1;i<=r;i++) c[mid][i] = Secret(c[mid][i-1],a[i]);
for(int i = mid-2;i>=l;i--) c[i][mid-1] = Secret(a[i],c[i+1][mid-1]);
init(l,mid-1);
init(mid+1,r);
}
void Init(int N, int A[]) {
n = N;
for(int i = 1;i<=n;i++) a[i] = A[i-1];
for(int i = 1;i<=n;i++) c[i][i] = a[i];
init(1,n);
}
int get(int tl,int tr,int l,int r){
if(l==r) return c[l][r];
int mid = (tl+tr)/2;
if(mid-1>=l&&mid<=r) return Secret(c[l][mid-1],c[mid][r]);
if(l>=mid) return get(mid+1,tr,l,r);
return get(tl,mid-2,l,r);
}
int Query(int L, int R) {
int ans = get(1,n,L+1,R+1);
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |