Submission #384093

# Submission time Handle Problem Language Result Execution time Memory
384093 2021-03-31T12:33:45 Z ritul_kr_singh Secret (JOI14_secret) C++17
Compilation error
0 ms 0 KB
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;

int b[1000][1000], n;

void PreCalc(int lx, int rx){
	if(rx-lx<=2) return;
	int mx = (lx+rx)/2;
	PreCalc(lx, mx);
	PreCalc(mx, rx);

	for(int i=mx-2; i>=0; --i)
		b[i][mx-1] = Secret(a[i], b[i+1][mx-1]);
	for(int i=mx+1; i<rx; ++i)
		b[mx][i] = Secret(b[mx][i-1], a[i]);
}

void Init(int N, int a[]){
	n = N;
	for(int i=0; i<1000; ++i)
		for(int j=0; j<1000; ++j)
			b[i][j] = i-j ? -1 : a[i];
	PreCalc(0, n);
}

int Calc(int l, int r, int lx, int rx){
	int mx = (lx+rx)/2;
	if(r<mx) return Calc(l, r, lx, mx);
	if(l>=mx) return Calc(l, r, mx, rx);
	return Secret(b[l][mx-1], b[mx][r]);
}

int Query(int L, int R){
	if(L==R) return b[L][L];
	if(L+1==R) return Secret(b[L][L], b[R][R]);
	return Calc(L, R, 0, n);
}

Compilation message

secret.cpp: In function 'void PreCalc(int, int)':
secret.cpp:14:23: error: 'a' was not declared in this scope
   14 |   b[i][mx-1] = Secret(a[i], b[i+1][mx-1]);
      |                       ^
secret.cpp:16:33: error: 'a' was not declared in this scope
   16 |   b[mx][i] = Secret(b[mx][i-1], a[i]);
      |                                 ^