# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
995255 | yeediot | Secret (JOI14_secret) | C++17 | 0 ms | 0 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"
#include "/Users/iantsai/Downloads/secret/grader.cpp"
using namespace std;
const int mxn = 1005;
int seg[4*mxn], a[mxn], n;
void build(int l,int r,int id){
if(l == r){
seg[id] = a[l];
return;
}
int mm = l+r>>1;
build(l, mm, id*2);
build(mm+1, r, id*2+1);
seg[id] = Secret(seg[id*2],seg[id*2+1]);
}
int query(int l,int r, int id,int ql,int qr){
if(ql <= l and r <= qr){
return seg[id];
}
int mm=l+r>>1;
if(qr<=mm){
return query(l,mm,id*2,ql,qr);
}
else if(ql>mm){
return query(mm+1,r,id*2+1,ql,qr);
}
else{
return Secret(query(l,mm,id*2,ql,mm),query(mm+1,r,id*2+1,mm+1,qr));
}
}
void Init(int N, int b[]){
n = N;
for(int i=1;i<=n;i++){
a[i] = b[i-1];
}
build(1,n,1);
}
int Query(int l,int r){
l++;
r++;
return query(1,n,1,l,r);
}