Submission #683887

#TimeUsernameProblemLanguageResultExecution timeMemory
683887amukkalirSecret (JOI14_secret)C++17
30 / 100
522 ms4508 KiB
#include "secret.h" #include <bits/stdc++.h> using namespace std; const int nax = 1e3; int tree[2][4*nax+5]; int a[nax+5]; int n; void build(int x, int l=0, int r=n-1, int idx=1){ if (l == r) { tree[x][idx] = a[l+x]; } else { int m = (l+r)>>1; build(x,l,m,idx<<1); build(x,m+1,r,idx<<1|1); tree[x][idx] = Secret(tree[x][idx<<1], tree[x][idx<<1|1]); } } int get(int x, int fr, int to, int l=0, int r=n-1, int idx=1) { if (fr <= l && r <= to) return tree[x][idx]; else { int m = (l+r)>>1; if (fr > m) { return get(x, fr, to, m+1, r, idx<<1|1); } else if (to <= m) { return get(x, fr, to, l, m, idx<<1); } else { //cerr << x << " " << fr << " " << to << " "<<l<<" " << r<<endl; int res = Secret(get(x, fr, to, l, m, idx<<1), get(x, fr, to, m+1, r, idx<<1|1)); //cerr << l << " " << r << " " << res << endl; return res; } } } void Init(int N, int A[]) { n=N; for(int i=0; i<N; i++) a[i] = A[i]; build(0); //build(1); } int Query(int L, int R) { return get(0,L,R); return get(L%2,L-(L%2),R-(L%2)); }
#Verdict Execution timeMemoryGrader output
Fetching results...