# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
851864 | mareksb | Secret (JOI14_secret) | C++14 | 378 ms | 4648 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>
using namespace std;
int num_of_elements = 0;
int mas[1000];
int segt[4010];
void init(int pos=1,int l=1, int r=num_of_elements-1){
if(l==r){
segt[pos]=mas[l];
return;
}
int mid=(l+r)/2;
init(pos*2,l,mid);
init(pos*2+1,mid+1, r);
segt[pos]=Secret(segt[pos*2],segt[pos*2+1]);
}
int sum(int i, int j, int l=1, int r=num_of_elements-1, int pos=1){
if(j<l||r<i)return 0;
if(i<=l&&r<=j)return segt[pos];
int mid=(l+r)/2;
return Secret(sum(i,j,l,mid,pos*2),sum(i,j,mid+1,r,pos*2+1));
}
void Init(int N, int A[]){
num_of_elements=N;
for(int i=0;i<N;i++){
mas[i]=A[i];
}
init();
}
int Query(int L, int R){
return sum(L,R);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |