Submission #70281

# Submission time Handle Problem Language Result Execution time Memory
70281 2018-08-22T14:41:06 Z MladenP Secret (JOI14_secret) C++17
100 / 100
727 ms 8684 KB
#include <bits/stdc++.h>
#include "secret.h"
#define mid (l+r)/2
#define I int
#define G return
using namespace std;
int n, i, a[1010], d[1010][1010];
void Z(int l, int r) {
	if(l >= r) return;
	for(i = mid+1; i <= r; i++) d[mid][i] = Secret(d[mid][i-1], a[i]);
	for(i = mid-2; i >= l; i--) d[i][mid-1] = Secret(a[i], d[i+1][mid-1]);
	Z(l, mid-1);Z(mid+1, r);
}
void Init(I N, I *A){for(i=0,n=N-1;i<N;i++)a[i]=A[i],d[i][i]=a[i];Z(0,n);}
int query(int l, int r, int L, int R) {
	if(L < mid && mid <= R) return Secret(d[L][mid-1],d[mid][R]);
	if(L == mid) return d[mid][R];
	if(mid < L) return query(mid+1, r, L, R);
	return query(l, mid-1, L, R);
}
I Query(I L,I R){G query(0,n,L,R);}
# Verdict Execution time Memory Grader output
1 Correct 189 ms 4472 KB Output is correct - number of calls to Secret by Init = 3331, maximum number of calls to Secret by Query = 1
2 Correct 198 ms 4520 KB Output is correct - number of calls to Secret by Init = 3340, maximum number of calls to Secret by Query = 1
3 Correct 192 ms 4616 KB Output is correct - number of calls to Secret by Init = 3349, maximum number of calls to Secret by Query = 1
4 Correct 687 ms 8592 KB Output is correct - number of calls to Secret by Init = 7491, maximum number of calls to Secret by Query = 1
5 Correct 646 ms 8592 KB Output is correct - number of calls to Secret by Init = 7499, maximum number of calls to Secret by Query = 1
6 Correct 659 ms 8616 KB Output is correct - number of calls to Secret by Init = 7499, maximum number of calls to Secret by Query = 1
7 Correct 702 ms 8616 KB Output is correct - number of calls to Secret by Init = 7499, maximum number of calls to Secret by Query = 1
8 Correct 711 ms 8684 KB Output is correct - number of calls to Secret by Init = 7499, maximum number of calls to Secret by Query = 1
9 Correct 727 ms 8684 KB Output is correct - number of calls to Secret by Init = 7499, maximum number of calls to Secret by Query = 1
10 Correct 697 ms 8684 KB Output is correct - number of calls to Secret by Init = 7499, maximum number of calls to Secret by Query = 1