Submission #661538

# Submission time Handle Problem Language Result Execution time Memory
661538 2022-11-26T01:58:31 Z rxlfd314 Secret (JOI14_secret) C++17
Compilation error
0 ms 0 KB
#include "secret.h"
int N, pref[1000][1000];
void precompute(int l, int r, int A[]) {
	int mid = l + r >> 1;
	pref[mid][mid] = A[mid];
	pref[mid+1][mid+1] = A[mid+1];
	for (int i = mid - 1; i >= l; i--) {
		pref[mid][i] = Secret(pref[mid][i+1], A[i]);
	}
	for (int i = mid + 2; i <= r; i++) {
		pref[mid+1][i] = Secret(pref[mid+1][i-1], A[i]);
	}
	if (l < mid) {
		precompute(l, mid);
	}
	if (mid + 1 < r) {
		precompute(mid + 1, r);
	}
}
void Init(int n, int A[]) {
	N = n;
	precompute(0, N - 1, A);
}
int Query(int l, int r) {
	int lo = 0, hi = N - 1;
	while (lo != hi) {
		int mid = lo + hi >> 1;
		if (l <= mid && mid < r) {
			return Secret(pref[mid][l], pref[mid+1][r]);
		}
		if (r == mid) {
			return pref[mid][l];
		}
		if (mid < l) {
			lo = mid + 1;
		} else {
			hi = mid;
		}
	}
	return pref[lo][lo];
}

Compilation message

secret.cpp: In function 'void precompute(int, int, int*)':
secret.cpp:4:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    4 |  int mid = l + r >> 1;
      |            ~~^~~
secret.cpp:14:20: error: too few arguments to function 'void precompute(int, int, int*)'
   14 |   precompute(l, mid);
      |                    ^
secret.cpp:3:6: note: declared here
    3 | void precompute(int l, int r, int A[]) {
      |      ^~~~~~~~~~
secret.cpp:17:24: error: too few arguments to function 'void precompute(int, int, int*)'
   17 |   precompute(mid + 1, r);
      |                        ^
secret.cpp:3:6: note: declared here
    3 | void precompute(int l, int r, int A[]) {
      |      ^~~~~~~~~~
secret.cpp: In function 'int Query(int, int)':
secret.cpp:27:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   27 |   int mid = lo + hi >> 1;
      |             ~~~^~~~