Submission #70225

# Submission time Handle Problem Language Result Execution time Memory
70225 2018-08-22T13:46:18 Z MladenP Secret (JOI14_secret) C++17
100 / 100
633 ms 8624 KB
#include <bits/stdc++.h>
#include "secret.h"
#define mid (l+r)/2
using namespace std;
#define MAXN 1010
int n, a[MAXN], d[MAXN][MAXN];
void init(int l, int r) {
	if(l >= r) return;
	for(int i = 0; i < n; i++) d[i][i] = a[i];
	for(int i = mid+1; i <= r; i++) d[mid][i] = Secret(d[mid][i-1], a[i]);
	for(int i = mid-2; i >= l; i--) d[i][mid-1] = Secret(a[i], d[i+1][mid-1]);
	init(l, mid-1); init(mid+1, r);
}
void Init(int N, int A[]) {
	n = N;
	for(int i = 1; i <= n; i++) a[i] = A[i-1];
	init(1, N);
}
int query(int l, int r, int L, int R) {
	if(L <= mid && mid <= R) {
		if(L < mid) return Secret(d[L][mid-1],d[mid][R]);
		else return d[mid][R];
	}
	if(mid < L) return query(mid+1, r, L, R);
	if(R < mid) return query(l, mid-1, L, R);
}
int Query(int L, int R) {
	L++; R++;
	if(L == R) return a[L];
	if(L+1 == R) return Secret(a[L], a[R]);
	return query(1, n, L, R);
}

Compilation message

secret.cpp: In function 'int query(int, int, int, int)':
secret.cpp:26:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Correct 174 ms 4344 KB Output is correct - number of calls to Secret by Init = 3331, maximum number of calls to Secret by Query = 1
2 Correct 194 ms 4580 KB Output is correct - number of calls to Secret by Init = 3340, maximum number of calls to Secret by Query = 1
3 Correct 193 ms 4604 KB Output is correct - number of calls to Secret by Init = 3349, maximum number of calls to Secret by Query = 1
4 Correct 611 ms 8392 KB Output is correct - number of calls to Secret by Init = 7491, maximum number of calls to Secret by Query = 1
5 Correct 632 ms 8392 KB Output is correct - number of calls to Secret by Init = 7499, maximum number of calls to Secret by Query = 1
6 Correct 629 ms 8448 KB Output is correct - number of calls to Secret by Init = 7499, maximum number of calls to Secret by Query = 1
7 Correct 606 ms 8448 KB Output is correct - number of calls to Secret by Init = 7499, maximum number of calls to Secret by Query = 1
8 Correct 613 ms 8460 KB Output is correct - number of calls to Secret by Init = 7499, maximum number of calls to Secret by Query = 1
9 Correct 633 ms 8460 KB Output is correct - number of calls to Secret by Init = 7499, maximum number of calls to Secret by Query = 1
10 Correct 617 ms 8624 KB Output is correct - number of calls to Secret by Init = 7499, maximum number of calls to Secret by Query = 1