Submission #908825

#TimeUsernameProblemLanguageResultExecution timeMemory
908825vjudge1Secret (JOI14_secret)C++17
30 / 100
441 ms4444 KiB
#include <iostream> #include "secret.h" using namespace std; int st[4005],a[1005],n; /* int Secret(int X, int Y){ return X+2*(Y/2); }*/ int qst(int nd,int l,int r,int a,int b){ //cout<<l<<" "<<r<<"\n"; if(a<=l&&r<=b)return st[nd]; int m=(l+r)/2; if(a<=m&&l<=b){ if(a<=r&&m+1<=b){ return Secret(qst(2*nd,l,m,a,b),qst(2*nd+1,m+1,r,a,b)); }else return qst(2*nd,l,m,a,b); }else return qst(2*nd+1,m+1,r,a,b); } int Query(int L, int R){ //cout<<"Query\n"; return qst(1,0,n-1,L,R); } int ist(int nd,int l,int r){ //cout<<l<<" "<<r<<"\n"; if(l==r) return st[nd]=a[l]; int m=(l+r)/2; return st[nd]=Secret(ist(2*nd,l,m),ist(2*nd+1,m+1,r)); } void Init(int N, int A[]){ //cout<<"Init\n"; n=N; for(int i=0;i<n;i++)a[i]=A[i]; ist(1,0,n-1); return; } /* int main(){ cin.tie(0);cout.tie(0);//ios_base::sync_with_stdio(0); //int a=16,b[16]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}; int a=8,b[8]={1,4,7,2,5,8,3,6}; Init(a,b); cout<<Query(0,3)<<"\n"; cout<<Query(1,7)<<"\n"; cout<<Query(5,5)<<"\n"; cout<<Query(2,4)<<"\n"; return 0; }*/
#Verdict Execution timeMemoryGrader output
Fetching results...