Submission #1056344

#TimeUsernameProblemLanguageResultExecution timeMemory
1056344MinbaevSecret (JOI14_secret)C++17
0 / 100
263 ms4412 KiB
#include "secret.h" using namespace std; const int nmax = 1000 + 5; using namespace std; int n, a[nmax]; int tree[nmax << 2]; void build(int id, int l, int r){ if(l == r){ tree[id] = a[l]; return; } int mid = (r + l)/2; build(id *2, l, mid); build(id *2 + 1, mid + 1, r); tree[id] = Secret(tree[id *2 ], tree[id * 1 + 1]); } int get(int id, int l, int r, int u, int v){ if(l >= u && r <= v) return tree[id]; int mid = (r + l) /2; if(mid< u) return get(id * 2 + 1, mid + 1, r, u, v); if(mid + 1 > v) return get(id * 2, l, mid, u, v); return Secret(get(id* 2, l, mid, u, v), get(id * 2 + 1, mid + 1, r, u, v)); } void Init(int N, int A[]){ n = N; for(int i = 0; i < n; ++i) a[i] = A[i]; build(1, 0, n - 1); } int Query(int l, int r){ return get(1, 0, n - 1, l, r); }
#Verdict Execution timeMemoryGrader output
Fetching results...