답안 #52453

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
52453 2018-06-26T04:10:41 Z tataky(#1353) 비밀 (JOI14_secret) C++11
컴파일 오류
0 ms 0 KB
#include "secret.h"

int sp[9][1001], to[9][1001], n;
int a[1001];

int Query(int L, int R) {
	if (L == R) return a[L];
	int dist = R - L;
	int ret, cur = L;
	bool fst = true;
	for (int h = 8; h >= 0; h--) if(dist&(1<<h)) {
		if (h == 9) {
			int val = Secret(sp[8][cur], sp[8][to[8][cur]]);
			ret = val; fst = false;
		}
		if (fst) {
			ret = sp[h][cur];
			cur = to[h][cur];
			fst = false;
		}
		else {
			ret = Secret(ret, sp[h][cur]);
			cur = to[h][cur];
		}
	return ret;
}

void setsparse() {
	for (int i = 0; i < n - 1; i++) {
		sp[i][0] = Secret(a[i], a[i + 1]);
		to[i][0] = i + 1;
	}
	for (int h = 1; h < 9; h++) {
		for (int i = 0; i < n; i++) if (i + (1 << h) < n) {
			to[h][i] = to[h - 1][to[h - 1][i]];
			sp[h][i] = Secret(sp[h - 1][i], sp[h - 1][to[h - 1][i]];
		}
	}
}

void Init(int N, int A[]) {
	n = N;
	for (int i = 0; i < n; i++)
		a[i] = A[i];
	setsparse();
}

Compilation message

secret.cpp: In function 'int Query(int, int)':
secret.cpp:28:18: error: a function-definition is not allowed here before '{' token
 void setsparse() {
                  ^
secret.cpp:41:27: error: a function-definition is not allowed here before '{' token
 void Init(int N, int A[]) {
                           ^
secret.cpp:46:1: error: expected '}' at end of input
 }
 ^
secret.cpp:46:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^