Submission #321623

# Submission time Handle Problem Language Result Execution time Memory
321623 2020-11-12T23:23:40 Z bigg Secret (JOI14_secret) C++14
100 / 100
510 ms 4552 KB
#include "secret.h"
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1010;
int tot, maxa;
int qual[MAXN][15];
int a[MAXN];
int n;
void recur(int l, int r, int altura){

	if(l >= r || l == r-1) return;
	int mid = (l + r)/2;
	qual[mid][altura] = a[mid];
	qual[mid+1][altura] = a[mid+1];
	for(int i = mid - 1; i >= l; i--)qual[i][altura] = Secret(a[i], qual[i+1][altura]);
	for(int i = mid + 2; i <= r; i++)qual[i][altura] = Secret(qual[i-1][altura], a[i]);
	recur(l, mid - 1, altura + 1);
	recur(mid + 1, r, altura + 1);
}
int makeans(int x, int y, int L, int R, int altura){
	int mid = (x+y)/2;
	if(R < mid) return makeans(x, mid - 1, L, R, altura + 1);
	if(L > mid) return(makeans(mid + 1, y, L, R, altura + 1));
	if(R == mid) return qual[L][altura];
	
	return Secret(qual[L][altura], qual[R][altura]);
}

void Init(int N, int A[]) {
	n = N;
  	for(int i = 1; i <= N; i++) a[i] = A[i-1];
	recur(1, n, 0);
	//printf("%d %d\n", tot, maxa);
}

int Query(int L, int R) {
	L++;
	R++;
	if(L==R) return a[L];
	if( L == R-1) return Secret(a[L], a[R]);
	return makeans(1,n,L,R,0);
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 140 ms 2540 KB Output is correct - number of calls to Secret by Init = 3331, maximum number of calls to Secret by Query = 1
2 Correct 147 ms 2668 KB Output is correct - number of calls to Secret by Init = 3339, maximum number of calls to Secret by Query = 1
3 Correct 142 ms 2540 KB Output is correct - number of calls to Secret by Init = 3347, maximum number of calls to Secret by Query = 1
4 Correct 510 ms 4552 KB Output is correct - number of calls to Secret by Init = 7467, maximum number of calls to Secret by Query = 1
5 Correct 502 ms 4460 KB Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1
6 Correct 499 ms 4460 KB Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1
7 Correct 505 ms 4460 KB Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1
8 Correct 501 ms 4460 KB Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1
9 Correct 501 ms 4356 KB Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1
10 Correct 506 ms 4460 KB Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1