Submission #703301

#TimeUsernameProblemLanguageResultExecution timeMemory
703301baneSecret (JOI14_secret)C++17
0 / 100
444 ms4428 KiB
#include <bits/stdc++.h> #include "secret.h" using namespace std; typedef long long ll; const int MAX = 10005; ll arr[MAX], ret[40][MAX], mask[MAX]; int n; void init(int l, int r, int dep = 0){ if (l == r) { ret[dep][l] = arr[l]; return; } int m = l+(r-l)/2; for (int i = m; i >= l; i--) ret[dep][i] = (i == m? arr[i] : Secret(arr[i], ret[dep][i+1])); for (int i = m+1; i <= r; i++) ret[dep][i] = (i == m+1? arr[i] : Secret(arr[i], ret[dep][i-1])); for (int i = m+1; i <= r; i++) mask[i] ^= (1<<dep); init(l, m, dep+1); init(m+1, r, dep+1); } void Init(int N_, int A[]) { n = N_; for (int i = 0; i < n; ++i)arr[i] = A[i]; init(0,n-1,0); } int get(int lvl, int l, int r, int L, int R) { if (l == r) return ret[lvl][L]; int m = (l + r) >> 1; if (R <= m) return get(lvl + 1, l, m, L, R); if (L >= m+1) return get(lvl + 1, m+1, r, L, R); return Secret(ret[lvl][L], ret[lvl][R]); } int Query(int L, int R) { return get(0,0,n-1,L,R); }
#Verdict Execution timeMemoryGrader output
Fetching results...