Submission #774462

#TimeUsernameProblemLanguageResultExecution timeMemory
774462colossal_pepeSecret (JOI14_secret)C++17
0 / 100
363 ms12316 KiB
#include "secret.h" #include <vector> using namespace std; int n; vector<vector<int>> tree(4005); void buildTree(int node, int l, int r, int a[]) { tree[node].resize(n); if (node % 2) { tree[node][l] = a[l]; for (int i = l + 1; i <= r; i++) { tree[node][i] = Secret(tree[node][i - 1], a[i]); } } else { tree[node][r] = a[r]; for (int i = r - 1; i >= l; i--) { tree[node][i] = Secret(tree[node][i + 1], a[i]); } } if (l != r) { int mid = (l + r) / 2; buildTree(2 * node, l, mid, a); buildTree(2 * node + 1, mid + 1, r, a); } } int query(int node, int l, int r, int L, int R) { if (l == r) return tree[node][l]; int mid = (l + r) / 2; if (R <= mid) return query(2 * node, l, mid, L, R); else if (L > mid) return query(2 * node + 1, mid + 1, r, L, R); else return Secret(tree[2 * node][L], tree[2 * node + 1][R]); } void Init(int N, int A[]) { n = N; buildTree(2, 0, (n - 1) / 2, A); buildTree(3, ((n - 1) / 2) + 1, n - 1, A); } int Query(int L, int R) { return query(1, 0, n - 1, L, R); }
#Verdict Execution timeMemoryGrader output
Fetching results...