답안 #901766

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
901766 2024-01-10T02:01:58 Z trMatherz 비밀 (JOI14_secret) C++17
컴파일 오류
0 ms 0 KB
include "secret.h"
int prefix[1000][1000], n;

void populate(int L, int R, int A[]) {
	int mid = (L + R) / 2;
	prefix[mid][mid] = A[mid];
	prefix[mid + 1][mid + 1] = A[mid + 1];

	for (int i = mid + 2; i <= R; i++)
		prefix[mid + 1][i] = Secret(prefix[mid + 1][i - 1], A[i]);
	for (int i = mid - 1; i >= L; i--)
		prefix[mid][i] = Secret(A[i], prefix[mid][i + 1]);

	if (L < mid) populate(L, mid, A);
	if (mid + 1 < R) populate(mid + 1, R, A);
}

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

int Query(int L, int R) {
	int a = 0, b = n - 1;

	while (a != b) {
		int mid = (a + b) / 2;
		if (mid >= L && mid < R)
			return Secret(prefix[mid][L], prefix[mid + 1][R]);
		else if (mid == R) return prefix[mid][L];
		else if (mid < L) a = mid + 1;
		else b = mid;
	}

	return prefix[a][a];
}

Compilation message

secret.cpp:1:1: error: 'include' does not name a type
    1 | include "secret.h"
      | ^~~~~~~
secret.cpp: In function 'void populate(int, int, int*)':
secret.cpp:6:2: error: 'prefix' was not declared in this scope
    6 |  prefix[mid][mid] = A[mid];
      |  ^~~~~~
secret.cpp:10:24: error: 'Secret' was not declared in this scope
   10 |   prefix[mid + 1][i] = Secret(prefix[mid + 1][i - 1], A[i]);
      |                        ^~~~~~
secret.cpp:12:20: error: 'Secret' was not declared in this scope
   12 |   prefix[mid][i] = Secret(A[i], prefix[mid][i + 1]);
      |                    ^~~~~~
secret.cpp: In function 'void Init(int, int*)':
secret.cpp:19:2: error: 'n' was not declared in this scope
   19 |  n = N;
      |  ^
secret.cpp: In function 'int Query(int, int)':
secret.cpp:24:17: error: 'n' was not declared in this scope
   24 |  int a = 0, b = n - 1;
      |                 ^
secret.cpp:29:18: error: 'prefix' was not declared in this scope
   29 |    return Secret(prefix[mid][L], prefix[mid + 1][R]);
      |                  ^~~~~~
secret.cpp:29:11: error: 'Secret' was not declared in this scope
   29 |    return Secret(prefix[mid][L], prefix[mid + 1][R]);
      |           ^~~~~~
secret.cpp:30:29: error: 'prefix' was not declared in this scope
   30 |   else if (mid == R) return prefix[mid][L];
      |                             ^~~~~~
secret.cpp:35:9: error: 'prefix' was not declared in this scope
   35 |  return prefix[a][a];
      |         ^~~~~~