답안 #52452

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
52452 2018-06-26T04:08:48 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;
	if (dist < 512) {
		int ret, cur = L;
		bool fst = false;
		for (int h = 8; h >= 0; h--) if(dist&(1<<h)) {
			if (fst) {
				ret = sp[h][cur];
				cur = to[h][cur];
			}
			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:23:9: error: 'ret' was not declared in this scope
  return ret;
         ^~~
secret.cpp: In function 'void setsparse()':
secret.cpp:34:59: error: expected ')' before ';' token
    sp[h][i] = Secret(sp[h - 1][i], sp[h - 1][to[h - 1][i]];
                                                           ^