Submission #337277

# Submission time Handle Problem Language Result Execution time Memory
337277 2020-12-19T08:04:21 Z nandonathaniel Secret (JOI14_secret) C++14
100 / 100
510 ms 8572 KB
#include "bits/stdc++.h"
#include "secret.h"
using namespace std;
const int MAXN=1005;
 
int N,A[MAXN],hasil[MAXN][MAXN],x,y;
 
void build(int L,int R){
	if(L==R){
		hasil[L][L]=A[L];
		return;
	}
	int mid=(L+R)/2;
	hasil[mid][mid]=A[mid];
	for(int i=mid-1;i>=L;i--)hasil[i][mid]=Secret(A[i],hasil[i+1][mid]);
	hasil[mid+1][mid+1]=A[mid+1];
	for(int i=mid+2;i<=R;i++)hasil[mid+1][i]=Secret(hasil[mid+1][i-1],A[i]);
	build(L,mid);
	build(mid+1,R);
}
 
int tanya(int L,int R){
	if(L==R)return hasil[L][L];
	int mid=(L+R)/2;
	if(y<=mid)return tanya(L,mid);
	if(x>=mid+1)return tanya(mid+1,R);
	return Secret(hasil[x][mid],hasil[mid+1][y]);
}
 
void Init(int n,int a[]) {
	N=n;
	for(int i=0;i<N;i++)A[i+1]=a[i];
	build(1,N);
}
 
int Query(int l, int r) {
	x=l;
	y=r;
	x++;y++;
    return tanya(1,N);
}
# Verdict Execution time Memory Grader output
1 Correct 142 ms 4460 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 4532 KB Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1
3 Correct 143 ms 4588 KB Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1
4 Correct 505 ms 8468 KB Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1
5 Correct 510 ms 8572 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
6 Correct 505 ms 8320 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
7 Correct 508 ms 8556 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 505 ms 8428 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 509 ms 8428 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 509 ms 8556 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1