# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
70212 |
2018-08-22T13:33:28 Z |
MladenP |
Secret (JOI14_secret) |
C++17 |
|
0 ms |
0 KB |
#include <bits/stdc++.h>
#include "secret.h"
#define STIZE(x) fprintf(stderr, "STIZE%lld\n", x);
#define PRINT(x) fprintf(stderr, "%s = %lld\n", #x, x);
#define NL(x) printf("%c", " \n"[(x)]);
#define lld long long
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define mid (l+r)/2
#define endl '\n'
#define all(a) begin(a),end(a)
#define sz(a) int((a).size())
#define LINF 1000000000000000LL
#define INF 1000000000
#define EPS 1e-9
using namespace std;
#define MAXN 1010
int n, a[MAXN], d[MAXN][MAXN];
void init(int l, int r) {
if(l == r) return;
for(int i = 0; i < n; i++) d[i][i] = a[i]
for(int i = mid+1; i <= r; i++) d[mid][i] = Secret(d[mid][i-1], a[i]);
for(int i = mid-2; i >= l; i--) d[i][mid-1] = Secret(a[i], d[i+1][mid-1]);
init(l, mid); init(mid+1, r);
}
void Init(int N, int A[]) {
n = N;
for(int i = 1; i <= n; i++) a[i] = A[i-1];
init(1, N);
}
int query(int l, int r, int L, int R) {
if(L <= mid && mid <= R) {
if(L < mid) return Secret(d[L][mid-1],d[mid][R]);
else return d[mid][R];
}
if(mid < L) return query(mid+1, r, L, R);
if(R < mid) return query(l, mid, L, R);
}
int Query(int L, int R) {
L++; R++;
if(L == R) return a[L];
if(L+1 == R) return Secret(a[L], a[R]);
return query(1, n, L, R);
}
Compilation message
secret.cpp: In function 'void init(int, int)':
secret.cpp:24:2: error: expected ';' before 'for'
for(int i = mid+1; i <= r; i++) d[mid][i] = Secret(d[mid][i-1], a[i]);
^~~
secret.cpp:24:21: error: 'i' was not declared in this scope
for(int i = mid+1; i <= r; i++) d[mid][i] = Secret(d[mid][i-1], a[i]);
^
secret.cpp: In function 'int query(int, int, int, int)':
secret.cpp:40:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^