Submission #698045

# Submission time Handle Problem Language Result Execution time Memory
698045 2023-02-12T06:02:22 Z badont Secret (JOI14_secret) C++17
0 / 100
440 ms 4684 KB
#include "secret.h"
#include <bits/stdc++.h>

using namespace std;
using pii = pair<int,int>;

struct Tree {
	vector<vector<int>> left, right;
	int n;

	void init(int n, const vector<int>& data) {
		this->n = n;
		left.resize(4 * n + 5);
		right.resize(4 * n + 5);

		auto dfs = [&](auto dfs, int z, int l, int r) -> void {
			int m = (l + r) >> 1;

			left[z].resize(m - l + 1);
			right[z].resize(r - m);

			if (l == r) {
				left[z][0] = data[l];
				return;
			}

			left[z][0] = data[m];
			for (int i = m - 1, idx = 1; i >= l; i--, idx++) {
				left[z][idx] = Secret(left[z][idx - 1], data[i]);
			}
			right[z][0] = data[m + 1];
			for (int i = m + 2, idx = 1; i <= r; i++, idx++) {
				right[z][idx] = Secret(right[z][idx - 1], data[i]);
			}

			dfs(dfs, 2 * z, l, m);
			dfs(dfs, 2 * z + 1, m + 1, r);
		};
		dfs(dfs, 1, 0, n - 1);
	}

	int query(int z, int l, int r, int ql, int qr) {
		int m = (l + r) >> 1;

		if (l == r) {
			return left[z][0];
		}

		if (qr <= m) return query(2 * z, l, m, ql, qr);
		if (ql >= m + 1) return query(2 * z + 1, m + 1, r, ql, qr);

		int idx1 = m - ql, idx2 = qr - (m + 1);
		if (ql == qr) return left[z][idx1];
		return Secret(left[z][idx1], right[z][idx2]);
	}

	int query(int ql, int qr) { return query(1, 0, n - 1, ql, qr); }
} tree;

void Init(int N, int A[]) {
	vector<int> a(N);
	for (int i = 0; i < N; i++)
		a[i] = A[i];

	tree.init(N, a);
}

int Query(int L, int R) {
	return tree.query(L, R);
}
# Verdict Execution time Memory Grader output
1 Incorrect 110 ms 2508 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 268854015.
2 Incorrect 126 ms 2504 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560.
3 Incorrect 111 ms 2500 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 353554500.
4 Incorrect 419 ms 4640 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 343081568.
5 Incorrect 432 ms 4548 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 957013316.
6 Incorrect 418 ms 4560 KB Wrong Answer: Query(200, 208) - expected : 277813445, actual : 154975445.
7 Incorrect 412 ms 4684 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 675449873.
8 Incorrect 440 ms 4676 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273091792.
9 Incorrect 417 ms 4512 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 827853577.
10 Incorrect 425 ms 4584 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 337854787.