# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
52454 |
2018-06-26T04:11:48 Z |
tataky(#1353) |
Secret (JOI14_secret) |
C++11 |
|
0 ms |
0 KB |
#include "secret.h"
int sp[9][1001], to[9][1001], n;
int a[1001];
int Query(int L, int R) {
if (L == R) return a[L];
int dist = R - L;
int ret, cur = L;
bool fst = true;
for (int h = 8; h >= 0; h--) if (dist&(1 << h)) {
if (h == 9) {
int val = Secret(sp[8][cur], sp[8][to[8][cur]]);
ret = val; fst = false;
}
if (fst) {
ret = sp[h][cur];
cur = to[h][cur];
fst = false;
}
else {
ret = Secret(ret, sp[h][cur]);
cur = to[h][cur];
}
}
return ret;
}
void setsparse() {
for (int i = 0; i < n - 1; i++) {
sp[i][0] = Secret(a[i], a[i + 1]);
to[i][0] = i + 1;
}
for (int h = 1; h < 9; h++) {
for (int i = 0; i < n; i++) if (i + (1 << h) < n) {
to[h][i] = to[h - 1][to[h - 1][i]];
sp[h][i] = Secret(sp[h - 1][i], sp[h - 1][to[h - 1][i]];
}
}
}
void Init(int N, int A[]) {
n = N;
for (int i = 0; i < n; i++)
a[i] = A[i];
setsparse();
}
Compilation message
secret.cpp: In function 'void setsparse()':
secret.cpp:37:59: error: expected ')' before ';' token
sp[h][i] = Secret(sp[h - 1][i], sp[h - 1][to[h - 1][i]];
^