Submission #69448

# Submission time Handle Problem Language Result Execution time Memory
69448 2018-08-20T22:20:26 Z MladenP Secret (JOI14_secret) C++17
Compilation error
0 ms 0 KB
#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 1000
int n, a[MAXN], d[MAXN][MAXN];
void init(int l, int r) {
	if(r < l) return;
	d[mid][mid] = a[mid];
	for(int i = mid+1; i <= r; i++) d[mid][i] = Secret(d[mid][i-1], a[i]);
	d[mid-1][mid-1] = a[mid-1];
	for(int i = mid-2; i >= l; i--) d[i][mid-1] = Secret(a[i], d[i+1][mid-1]);
	init(l, mid-1); init(mid+1, r);
}
void Init(int N, int A[]) {
	n = N;
	for(int i = 0; i < n; i++) a[i] = A[i];
	init(0, N-1);
}
int query(int l, int r, int L, int R) {
	if(L <= mid-1 && mid <= R) return Secret(d[L][mid-1],d[mid][R]);
	if(mid < L) return query(mid+1, r, L, R);
	if(R < mid) return query(l, mid-1, L, R);

}
int Query(int L, int R) {
	if(L == R) return a[L];
	if(L+1 == R) return Secret(a[L], a[R]);
	return query(0, n-1, L, R);
}

Compilation message

secret.cpp: In function 'void init(int, int)':
secret.cpp:11:4: error: 'mid' was not declared in this scope
  d[mid][mid] = a[mid];
    ^~~
secret.cpp:11:4: note: suggested alternative: 'void'
  d[mid][mid] = a[mid];
    ^~~
    void
secret.cpp:12:46: error: 'Secret' 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:14:48: error: 'Secret' was not declared in this scope
  for(int i = mid-2; i >= l; i--) d[i][mid-1] = Secret(a[i], d[i+1][mid-1]);
                                                ^~~~~~
secret.cpp: In function 'int query(int, int, int, int)':
secret.cpp:23:10: error: 'mid' was not declared in this scope
  if(L <= mid-1 && mid <= R) return Secret(d[L][mid-1],d[mid][R]);
          ^~~
secret.cpp:23:10: note: suggested alternative: 'void'
  if(L <= mid-1 && mid <= R) return Secret(d[L][mid-1],d[mid][R]);
          ^~~
          void
secret.cpp:23:36: error: 'Secret' was not declared in this scope
  if(L <= mid-1 && mid <= R) return Secret(d[L][mid-1],d[mid][R]);
                                    ^~~~~~
secret.cpp:24:5: error: 'mid' was not declared in this scope
  if(mid < L) return query(mid+1, r, L, R);
     ^~~
secret.cpp:24:5: note: suggested alternative: 'void'
  if(mid < L) return query(mid+1, r, L, R);
     ^~~
     void
secret.cpp:25:9: error: 'mid' was not declared in this scope
  if(R < mid) return query(l, mid-1, L, R);
         ^~~
secret.cpp:25:9: note: suggested alternative: 'void'
  if(R < mid) return query(l, mid-1, L, R);
         ^~~
         void
secret.cpp: In function 'int Query(int, int)':
secret.cpp:30:22: error: 'Secret' was not declared in this scope
  if(L+1 == R) return Secret(a[L], a[R]);
                      ^~~~~~