Submission #851864

#TimeUsernameProblemLanguageResultExecution timeMemory
851864mareksbSecret (JOI14_secret)C++14
0 / 100
378 ms4648 KiB
#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 timeMemoryGrader output
Fetching results...