Submission #699746

# Submission time Handle Problem Language Result Execution time Memory
699746 2023-02-17T21:45:22 Z boyliguanhan Secret (JOI14_secret) C++17
100 / 100
480 ms 8184 KB
#include "secret.h"
int calc[1000][1000], n;
void init(int l, int r, int a[]) {
	int mid = (l + r) / 2;
	calc[mid][mid] = a[mid];
	calc[mid + 1][mid + 1] = a[mid + 1];
	for (int i = mid + 2; i <= r; i++)
		calc[mid + 1][i] = Secret(calc[mid + 1][i - 1], a[i]);
	for (int i = mid - 1; i >= l; i--)
		calc[mid][i] = Secret(a[i], calc[mid][i + 1]);
	if (l < mid)
		init(l, mid, a);
	if (r > mid + 1)
		init(mid + 1, r, a);
}
void Init(int N, int A[]) {
	n = N;
	init(0, n - 1, A);
}

int Query(int L, int R) {
	int l = 0, r = n - 1;
	while (l < r) {
		int mid = (l + r) / 2;
		if (L <= mid && mid < R) return Secret(calc[mid][L], calc[mid + 1][R]);
		else if (mid == R) return calc[mid][L];
		else if (mid + 1 == L) return calc[mid + 1][R];
		else if (mid < L) l = mid + 1;
		else r = mid;
	}
	return calc[l][l];
}
# Verdict Execution time Memory Grader output
1 Correct 125 ms 4244 KB Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1
2 Correct 120 ms 4256 KB Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1
3 Correct 122 ms 4304 KB Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1
4 Correct 480 ms 8140 KB Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1
5 Correct 431 ms 8176 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
6 Correct 431 ms 8140 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
7 Correct 451 ms 8096 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 480 ms 8172 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 444 ms 8172 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 462 ms 8184 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1