Submission #657769

#TimeUsernameProblemLanguageResultExecution timeMemory
657769hollwo_pelwSecret (JOI14_secret)C++17
0 / 100
452 ms8648 KiB
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;

// Secret(int x, int y);

int calc[1 << 10][1 << 10];

void Init(int N, int A[]) {
	memset(calc, -1, sizeof calc);
	for (int i = 0; i < N; i++)
		calc[i][i] = A[i];
	for (int i = 10; i; i --) {
		for (int L = 0; L < N; L += 1 << i) {
			int M = min(N, L + (1 << (i - 1)));
			int R = min(N - 1, L + (1 << i));
			for (int j = M + 1; j <= R; j++)
				calc[M][j] = Secret(calc[M][j - 1], A[j]);
			for (int j = M - 2; j >= L; j--)
				calc[j][M - 1] = Secret(calc[j + 1][M - 1], A[j]);
		}
	}
}

int Query(int L, int R) {
	if (calc[L][R] >= 0)
		return calc[L][R];
	for (int M = L; M < R; M++) {
		if (calc[L][M] >= 0 && calc[M + 1][R] >= 0)
			return Secret(calc[L][M], calc[M + 1][R]);
	}
}

Compilation message (stderr)

secret.cpp: In function 'int Query(int, int)':
secret.cpp:32:1: warning: control reaches end of non-void function [-Wreturn-type]
   32 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...