답안 #657773

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
657773 2022-11-11T02:12:14 Z hollwo_pelw 비밀 (JOI14_secret) C++17
100 / 100
435 ms 8492 KB
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
 
// Secret(int x, int y);
 
int calc[1 << 10][1 << 10];
 
void solve(int L, int R, int A[]) {
	if (L == R) return ;
	int M = (L + R + 1) >> 1;
	for (int j = M + 1; j <= R; j++)
		calc[M][j] = Secret(calc[M][j - 1], A[j]);
	for (int j = M - 2; j >= L; j--)
		calc[j][M - 1] = Secret(A[j], calc[j + 1][M - 1]);
	solve(L, M - 1, A);
	solve(M, R, A);
}
 
void Init(int N, int A[]) {
	memset(calc, -1, sizeof calc);
	for (int i = 0; i < N; i++)
		calc[i][i] = A[i];
	solve(0, N - 1, A);
}
 
int Query(int L, int R) {
	if (calc[L][R] >= 0)
		return calc[L][R];
	for (int M = L; M < R; M++) {
		if (calc[L][M] >= 0 && calc[M + 1][R] >= 0)
			return Secret(calc[L][M], calc[M + 1][R]);
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 122 ms 6348 KB Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1
2 Correct 125 ms 6408 KB Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1
3 Correct 123 ms 6372 KB Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1
4 Correct 428 ms 8284 KB Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1
5 Correct 431 ms 8376 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
6 Correct 427 ms 8492 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
7 Correct 434 ms 8296 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 435 ms 8332 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 433 ms 8376 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 434 ms 8276 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1