Submission #52469

# Submission time Handle Problem Language Result Execution time Memory
52469 2018-06-26T05:05:14 Z 0^0(#1358) Secret (JOI14_secret) C++11
100 / 100
658 ms 8624 KB
#include <bits/stdc++.h>
#include "secret.h"
using namespace std;
int dp[1005][1005];
int n;
void init(int arr[], int le, int ri) {
	if (le == ri) {
		dp[le][ri] = arr[le];
		return;
	}
	int mid = (le + ri) / 2;
	init(arr, le, mid);
	init(arr, mid + 1, ri);
	dp[mid][mid] = arr[mid];
	for (int i = mid - 1; i >= le; i--)
		dp[i][mid] = Secret(arr[i], dp[i + 1][mid]);
	dp[mid + 1][mid + 1] = arr[mid + 1];
	for (int i = mid + 2; i <= ri; i++)
		dp[mid + 1][i] = Secret(dp[mid + 1][i - 1], arr[i]);
}
int query(int le, int ri, int nodele, int noderi) {
	if (nodele == noderi)return dp[le][le];
	int mid = (nodele + noderi) / 2;
	if (ri <= mid)return query(le, ri, nodele, mid);
	if (le >= mid + 1)return query(le, ri, mid + 1, noderi);
	return Secret(dp[le][mid], dp[mid + 1][ri]);
}
void Init(int N, int A[]) {
	n = N;
	init(A, 0, N - 1);
}

int Query(int L, int R) {
	return query(L, R, 0, n - 1);
}
# Verdict Execution time Memory Grader output
1 Correct 190 ms 4500 KB Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1
2 Correct 196 ms 4516 KB Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1
3 Correct 192 ms 4544 KB Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1
4 Correct 645 ms 8444 KB Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1
5 Correct 617 ms 8444 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
6 Correct 603 ms 8624 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
7 Correct 641 ms 8624 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 620 ms 8624 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 658 ms 8624 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 632 ms 8624 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1