답안 #930308

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
930308 2024-02-19T10:37:53 Z noyancanturk 비밀 (JOI14_secret) C++17
100 / 100
369 ms 4528 KB
#include "secret.h"
#include <cassert>
const int lim=1100;

int n,*a;
int aa[15][lim];

void dnc(int l,int r,int dep=0){
	if(l==r){
		return;
	}
	int mid=(l+r)>>1;
	aa[dep][mid]=a[mid];
	for(int i=mid-1;l<=i;i--){
		aa[dep][i]=Secret(a[i],aa[dep][i+1]);
	}
	aa[dep][mid+1]=a[mid+1];
	for(int i=mid+2;i<=r;i++){
		aa[dep][i]=Secret(aa[dep][i-1],a[i]);
	}
	dnc(l,mid,dep+1),dnc(mid+1,r,dep+1);
}

void Init(int N, int A[]) {
	n=N;
	a=A;
	dnc(0,n-1);
}

int Query(int L, int R) {
	if(L==R){
		return a[L];
	}
	int l=0,r=n-1,dep=0;
	while(l<=r){
		int mid=(l+r)>>1;
		if(L<=mid&&mid<R){
			return Secret(aa[dep][L],aa[dep][R]);
		}else if(mid+1==L){
			return aa[dep][R];
		}
		else if(mid==R){
			return aa[dep][L];
		}else if(mid<L){
			l=mid+1;
		}else{
			r=mid;
		}
		dep++;
	}
	return -1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 101 ms 3660 KB Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1
2 Correct 103 ms 3572 KB Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1
3 Correct 107 ms 3664 KB Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1
4 Correct 357 ms 4188 KB Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1
5 Correct 360 ms 4392 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
6 Correct 356 ms 4432 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
7 Correct 363 ms 4396 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 356 ms 4188 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 369 ms 4528 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 359 ms 4432 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1