# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
881485 | smartmonky | Secret (JOI14_secret) | C++14 | 386 ms | 8372 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"
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;
int b[1005];
int t[1005][1005];
int cnt = 0;
int N;
void build(int l = 0, int r = N - 1){
if(l > r)return;
if(l == r){
t[l][r] = b[l];
return;
}
int mid = (l + r) >> 1;
t[mid][mid] = b[mid];
for(int i = mid - 1; i >= l; i--){
t[i][mid] = Secret(b[i], t[i + 1][mid]);
}
for(int i = mid + 1; i <= r; i++){
t[mid][i] = Secret(b[i], t[i - 1][mid]);
}
build(l, mid);
build(mid + 1, r);
}
int get(int al, int ar, int l = 0, int r = N - 1){
if(al > r || ar < l)return 0;
int mid = (l + r) >> 1;
if(l == r)
return b[l];
if(l >= al && ar <= r)
return Secret(t[l][mid], t[mid + 1][r]);
else{
return get(al, ar, l, mid) + get(al, ar, mid + 1, r);
}
}
int Query(int l, int r){
return get(l, r);
}
void Init(int n, int a[])
{
N = n;
for(int i=0;i<n;i++)b[i]=a[i];
build();
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |