Submission #1043388

#TimeUsernameProblemLanguageResultExecution timeMemory
1043388BF001Secret (JOI14_secret)C++17
0 / 100
274 ms4440 KiB
#include "secret.h" #include<bits/stdc++.h> using namespace std; #define NN 1005 #define K 15 int lf[K][NN], rt[K][NN], n; void divi(int lv, int l, int r, int A[]){ if (l == r){ lf[lv][l] = A[l - 1]; return; } int mid = (l + r) >> 1; lf[lv][mid] = A[mid - 1]; for (int i = mid - 1; i >= l; i--){ lf[lv][i] = Secret(A[i - 1], lf[lv][i + 1]); } rt[lv][mid + 1] = A[mid]; for (int i = mid + 2; i <= r; i++){ rt[lv][i] = Secret(A[i - 1], rt[lv][i - 1]); } divi(lv + 1, l, mid, A); divi(lv + 1, mid + 1, r, A); } int get(int lv, int l, int r, int u, int v){ int mid = (l + r) >> 1; if (u <= mid && r >= mid){ int rtt = lf[lv][u]; if (v > mid) rtt = Secret(rtt, rt[lv][v]); return rtt; } if (v < mid) return get(lv + 1, l, mid, u, v); return get(lv + 1, mid + 1, r, u, v); } void Init(int N, int A[]){ n = N; divi(0, 1, n, A); } int Query(int L, int R){ L++; R++; return get(0, 1, n, L, R); }
#Verdict Execution timeMemoryGrader output
Fetching results...