답안 #704610

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
704610 2023-03-02T12:21:07 Z dubabuba 비밀 (JOI14_secret) C++14
0 / 100
418 ms 8596 KB
#include "secret.h"

const int mxn = 110;
int range[mxn][mxn];
int n, a[mxn];

int build(int l, int r, int a[]) {
	if(l == r) return range[l][r] = a[l];
	if(l == r - 1) return range[l][r] = Secret(a[l], a[r]);

	build(l, (l + r) / 2, a);
	build((l + r) / 2 + 1, r, a);

	int m = (l + r) / 2;
	range[m][m] = a[m];
	for(int s = m - 1; s >= l; s--)
		range[s][m] = Secret(a[s], range[s + 1][m]);

	m++;
	range[m][m] = a[m];
	for(int e = m + 1; e <= r; e++)
		range[m][e] = Secret(range[m][e - 1], a[e]);

	return 0;
}

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

int Query(int L, int R) {
	int l = 0, r = n - 1;
	while(r - l > 1) {
		int m = (l + r) / 2;

		if(L == m) return range[L][R];
		if(R == m) return range[L][R];
		if(L <= m && m < R) return Secret(range[L][m], range[m + 1][R]);
		if(m < L) l = m;
		else r = m + 1;
	}
	return range[L][R];
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 109 ms 4696 KB Execution killed with signal 11
2 Runtime error 110 ms 4692 KB Execution killed with signal 11
3 Runtime error 110 ms 4676 KB Execution killed with signal 11
4 Runtime error 410 ms 8524 KB Execution killed with signal 11
5 Runtime error 410 ms 8524 KB Execution killed with signal 11
6 Runtime error 413 ms 8548 KB Execution killed with signal 11
7 Runtime error 410 ms 8596 KB Execution killed with signal 11
8 Runtime error 414 ms 8528 KB Execution killed with signal 11
9 Runtime error 412 ms 8532 KB Execution killed with signal 11
10 Runtime error 418 ms 8536 KB Execution killed with signal 11