# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
790485 | Andrey | Secret (JOI14_secret) | C++14 | 419 ms | 4356 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 pr[1001][10];
int su[1001][10];
void Init(int n, int a[]) {
for(int i = 0; i < n; i++) {
pr[i][0] = a[i];
su[i][0] = a[i];
}
for(int i = 1; i < 10; i++) {
for(int j = 0; j < n; j++) {
if(j%(1 << i) < (1 << (i-1))) {
pr[j][i] = pr[j][i-1];
}
else {
pr[j][i] = Secret(pr[j-1][i],a[j]);
}
}
}
for(int i = 1; i < 10; i++) {
for(int j = n-1; j >= 0; j--) {
if(j%(1 << i) == 0) {
su[j][i] = pr[min(n-1,j+(1 << i)-1)][i];
}
else {
if(j%(1 << i) >= (1 << (i-1)) || j == n-1) {
su[j][i] = su[j][i-1];
}
else {
su[j][i] = Secret(a[j],su[j+1][i]);
}
}
}
}
}
int Query(int l, int r) {
if(l == r) {
return pr[l][0];
}
for(int i = 0; i < 10; i++) {
if(l/(1 << (i+1)) == r/(1 << (i+1))) {
return Secret(su[l][i],pr[r][i]);
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |