Submission #297675

# Submission time Handle Problem Language Result Execution time Memory
297675 2020-09-11T17:56:07 Z penguinhacker Secret (JOI14_secret) C++17
6 / 100
525 ms 4856 KB
#include <bits/stdc++.h>
#include "secret.h"
using namespace std;

/*int Secret(int a, int b) {
	return min(a, b);
}*/

const int mxN = 1000, mxK = 12;
int n, a[mxN];
int tl[mxN][mxK], tr[mxN][mxK];

void Init(int N, int A[]) {
	n = N;
	for (int i = 0; i < n; ++i) {
		a[i] = A[i];
	}
	for (int j = 0; (1 << j) <= n; ++j) {
		int mask = (1 << j) - 1;
		int temp;
		for (int i = 0; i < n; ++i) {
			temp = ((i & mask) == 0) ? a[i] : Secret(temp, a[i]);
			tl[i][j] = temp;
		}
		for (int i = n - 1; ~i; --i) {
			temp = ((i & mask) == mask) ? a[i] : Secret(a[i], temp);
			tr[i][j] = temp;
		}
	}
}

int Query(int L, int R) {
	if (L == R) return a[L];
	int x = 31 - __builtin_clz(L ^ R);
	return Secret(tr[L][x], tl[R][x]);
}

/*int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	int a[3] = {2, 1, 3};
	Init(3, a);
	for (int i = 0; i < 3; ++i) for (int j = i; j < 3; ++j) cout << i << " " << j << " " << Query(i, j) << "\n";
	return 0;
}*/

Compilation message

secret.cpp: In function 'void Init(int, int*)':
secret.cpp:22:44: warning: 'temp' may be used uninitialized in this function [-Wmaybe-uninitialized]
   22 |    temp = ((i & mask) == 0) ? a[i] : Secret(temp, a[i]);
      |                                      ~~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 148 ms 2556 KB Output is correct - number of calls to Secret by Init = 7164, maximum number of calls to Secret by Query = 1
2 Partially correct 149 ms 2680 KB Output isn't correct - number of calls to Secret by Init = 8194, maximum number of calls to Secret by Query = 1
3 Partially correct 155 ms 2552 KB Output isn't correct - number of calls to Secret by Init = 8203, maximum number of calls to Secret by Query = 1
4 Partially correct 517 ms 4500 KB Output isn't correct - number of calls to Secret by Init = 15991, maximum number of calls to Secret by Query = 1
5 Partially correct 514 ms 4660 KB Output isn't correct - number of calls to Secret by Init = 16006, maximum number of calls to Secret by Query = 1
6 Partially correct 513 ms 4856 KB Output isn't correct - number of calls to Secret by Init = 16006, maximum number of calls to Secret by Query = 1
7 Partially correct 520 ms 4472 KB Output isn't correct - number of calls to Secret by Init = 16006, maximum number of calls to Secret by Query = 1
8 Partially correct 514 ms 4472 KB Output isn't correct - number of calls to Secret by Init = 16006, maximum number of calls to Secret by Query = 1
9 Partially correct 525 ms 4472 KB Output isn't correct - number of calls to Secret by Init = 16006, maximum number of calls to Secret by Query = 1
10 Partially correct 520 ms 4600 KB Output isn't correct - number of calls to Secret by Init = 16006, maximum number of calls to Secret by Query = 1