Submission #885380

# Submission time Handle Problem Language Result Execution time Memory
885380 2023-12-09T14:54:13 Z Yey Secret (JOI14_secret) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "secret.h"
using namespace std;

int node[10][1030];
int n;
int b[1030];
int x;
int mx = 0;

void build(int depth,int l,int r){
	int m = (l+r)/2;
	if( !(0 <= m && m < x) ) return;
	node[depth][m] = b[m];
	for(int i = m-1 ; i >= l ; i--){
		node[depth][i] = getClue(b[i],node[depth][i+1]);
	}
	if( m+1 < r && m+1 < x ){
		node[depth][m+1] = b[m+1];
		for(int i = m+2; i < r ; i++){
			if( 0 <= i && i < x ) node[depth][i] = getClue(b[i],node[depth][i-1]);
		}
	}
	//~ cout<<depth<<":\n";
	//~ for(int i = l ; i < r ; i++) if( i < x ) cout<<i<<" "<<node[depth][i]<<"\n";
	if( r-l > 1 ){
		build(depth+1,l,m);
		build(depth+1,m,r);
	}
}

int q(int l,int r){
	if( l == r ) return b[l];
	int p = __builtin_clz(l^r) ^ 31;
	int pp = mx - 1 - p;
	//~ cout<<p<<"\n";
	int res = node[pp][l];
	if(r & ((1<<p) - 1)){
		res = getClue(res,node[p][r]);
	}
	return res;
}

void init(int N, std::vector<int> a) {
	x = n = N;
	int k = 1;
	while( k < n ) {
		k *= 2;
		mx++;
	}
	n = k;
	for(int i = 0 ; i < (int) a.size() ; i++) b[i] = a[i];
	build(0,0,n);
}

int query(int l, int r) {
	return q(l,r);
    return 0;
}

Compilation message

secret.cpp: In function 'void build(int, int, int)':
secret.cpp:16:20: error: 'getClue' was not declared in this scope
   16 |   node[depth][i] = getClue(b[i],node[depth][i+1]);
      |                    ^~~~~~~
secret.cpp:21:43: error: 'getClue' was not declared in this scope
   21 |    if( 0 <= i && i < x ) node[depth][i] = getClue(b[i],node[depth][i-1]);
      |                                           ^~~~~~~
secret.cpp: In function 'int q(int, int)':
secret.cpp:39:9: error: 'getClue' was not declared in this scope
   39 |   res = getClue(res,node[p][r]);
      |         ^~~~~~~