제출 #7006

#제출 시각아이디문제언어결과실행 시간메모리
7006gs13068비밀 (JOI14_secret)C++98
100 / 100
656 ms169116 KiB
#include "secret.h"

static int a[2048];
static int s[20480];
static int e[20480];
int l[20480][1024];
int r[20480][1024];

static void calc(int x)
{
	if(e[x]-s[x]>1)
	{
		int i,j,m=(s[x]+e[x])>>1;
		j=a[m-1];
		l[x][m-1]=j;
		for(i=m-2;i>=s[x];i--)
		{
			j=Secret(a[i],j);
			l[x][i]=j;
		}
		j=a[m];
		r[x][m]=j;
		for(i=m+1;i<e[x];i++)
		{
			j=Secret(j,a[i]);
			r[x][i]=j;
		}
		s[x<<1]=s[x];
		e[x<<1]=m;
		calc(x<<1);
		s[(x<<1)+1]=m;
		e[(x<<1)+1]=e[x];
		calc((x<<1)+1);
	}
}

static int get(int x,int L,int R)
{
	if(L==R)return a[L];
	int m=(s[x]+e[x])>>1;
	if(L<m&&m<=R)return Secret(l[x][L],r[x][R]);
	if(R<m)return get(x<<1,L,R);
	return get((x<<1)+1,L,R);
}

void Init(int N, int A[])
{
	int i;
	for(i=0;i<N;i++)a[i]=A[i];
	s[1]=0;
	e[1]=1000;
    calc(1);
}

int Query(int L, int R)
{
	return get(1,L,R);
}

컴파일 시 표준 에러 (stderr) 메시지


#Verdict Execution timeMemoryGrader output
Fetching results...