# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
605856 | kawaii | Secret (JOI14_secret) | C++14 | 507 ms | 8296 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "secret.h"
#include<bits/stdc++.h>
using namespace std;
int a[1005], pre[1005][1005];
void Init(int N, int A[]){
for(int i = 0; i < N; i++) a[i] = A[i];
for(int i = 0; i < N - 1; i++) pre[i][i + 1] = Secret(a[i], a[i + 1]);
for(int i = 2; i <= 9; i++){
for(int j = 0; j + (1 << i) - 1 < N; j++){
pre[j][j + (1 << i) - 1] = Secret(pre[j][j + (1 << i - 1) - 1], pre[j + (1 << i - 1)][j + (1 << i) - 1]);
}
}
}
int Query(int L, int R){
int ans = a[L];
int diff = R - L + 1;
while(diff){
int p = (diff & -diff);
// cout << diff <<" "<< p << "\n";
ans = Secret(ans, pre[L][L + p - 1]);
diff -= p; L += p;
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |