답안 #657771

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
657771 2022-11-11T02:11:13 Z hollwo_pelw 비밀 (JOI14_secret) C++17
컴파일 오류
0 ms 0 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) {
	if (L == R) return 0;
	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);
	solve(M, R);
}

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);
}

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;
}

Compilation message

secret.cpp: In function 'void solve(int, int)':
secret.cpp:10:21: error: return-statement with a value, in function returning 'void' [-fpermissive]
   10 |  if (L == R) return 0;
      |                     ^
secret.cpp:13:39: error: 'A' was not declared in this scope
   13 |   calc[M][j] = Secret(calc[M][j - 1], A[j]);
      |                                       ^
secret.cpp:15:27: error: 'A' was not declared in this scope
   15 |   calc[j][M - 1] = Secret(A[j], calc[j + 1][M - 1]);
      |                           ^