Submission #93526

# Submission time Handle Problem Language Result Execution time Memory
93526 2019-01-09T10:44:07 Z Dat160601 Secret (JOI14_secret) C++14
100 / 100
503 ms 8464 KB
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second

int n, val[1007][1007], a[1007];

void prep(int l, int r){
	if(l == r) return;
	int mid = (l + r) >> 1;
	for(int i = mid - 1; i >= l; i--){
		val[i][mid] = Secret(a[i - 1], val[i + 1][mid]);
	}
	for(int i = mid + 2; i <= r; i++){
		val[mid + 1][i] = Secret(val[mid + 1][i - 1], a[i - 1]);
	}
	prep(l, mid);
	prep(mid + 1, r);
}

void Init(int N, int A[]){
	n = N;
	for(int i = 0; i < n; i++) a[i] = A[i], val[i + 1][i + 1] = a[i];
	prep(1, N);
}

int solve(int l, int r, int L, int R){
	if(L == R) return a[L - 1];
	int mid = (l + r) >> 1;
	if(L <= mid && R > mid) return Secret(val[L][mid], val[mid + 1][R]);
	if(R <= mid) return solve(l, mid, L, R);
	else return solve(mid + 1, r, L, R);
}

int Query(int L, int R){
	return solve(1, n, L + 1, R + 1);
}
# Verdict Execution time Memory Grader output
1 Correct 146 ms 4472 KB Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1
2 Correct 143 ms 4476 KB Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1
3 Correct 144 ms 4436 KB Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1
4 Correct 497 ms 8312 KB Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1
5 Correct 494 ms 8216 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
6 Correct 494 ms 8440 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
7 Correct 500 ms 8432 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 499 ms 8324 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 503 ms 8464 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 501 ms 8376 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1