# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
605893 | kawaii | Secret (JOI14_secret) | C++14 | 496 ms | 8428 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 = 1; i <= N; i++) a[i] = A[i - 1];
for(int i = 1; i <= N; i++) pre[i][i] = a[i];
for(int i = 1; i <= 9; i++){
for(int j = 1; 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 = -1; L++; R++;
int diff = R - L + 1;
// cout << diff <<" ";
for(int i = 0; i <= 9; i++){
if((1 << i) & diff){
if(ans == -1) ans = pre[L][L + (1 << i) - 1];
else ans = Secret(ans, pre[L][L + (1 << i) - 1]);
L += (1 << i);
}
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |