Submission #85561

# Submission time Handle Problem Language Result Execution time Memory
85561 2018-11-20T23:30:46 Z KCSC Secret (JOI14_secret) C++14
0 / 100
595 ms 5672 KB
#include <bits/stdc++.h>
using namespace std;

int Secret(int x, int y);
void Init(int n, int arr[]);
int Query(int le, int ri);
/*
int Secret(int x, int y) {
	return x xor y xor 13; }
*/
int secret(int x, int y) {
	static map<pair<int, int>, int> mmp;
	if (mmp.find(make_pair(x, y)) != mmp.end()) {
		return mmp[make_pair(x, y)]; }
	else
		return (mmp[make_pair(x, y)] = Secret(x, y)); }

const int DIM = 1005;
vector<int> lef[DIM * 4], rig[DIM * 4];

void build(int nd, int le, int ri, int arr[]) {
	if (le != ri) {
		int md = (le + ri) / 2;
		build(nd * 2, le, md, arr);	
		build(nd * 2 + 1, md + 1, ri, arr); }
	if (nd != 1) { 
		lef[nd].resize(ri - le + 1); lef[nd][0] = arr[le];
		rig[nd].resize(ri - le + 1); rig[nd][ri - le] = arr[ri];
		if (le != ri) {
			int md = (le + ri) / 2;
			for (int i = 0; i <= ri - le; ++i) {
				lef[nd][i] = (i < md - le) ? lef[nd * 2][i] : secret(lef[nd][i - 1], arr[le + i]); }
			for (int i = ri - le - 1; i >= 0; --i) {
				rig[nd][i] = (i > md - le) ? rig[nd * 2 + 1][i] : secret(arr[le + i], rig[nd][i + 1]); } } } } 
		

int query(int nd, int le, int ri, int st, int en) {
	if (le == ri) {
		return lef[nd][0]; }
	else {
		int md = (le + ri) / 2;
		if (en <= md) {
			return query(nd * 2, le, md, st, en); }
		if (md <  st) {
			return query(nd * 2 + 1, md + 1, ri, st, en); }
		return secret(rig[nd * 2][st - le], lef[nd * 2 + 1][en - (md + 1)]); } } 

int _n;
void Init(int n, int arr[]) {
	build(1, 0, n - 1, arr); _n = n; }

int Query(int le, int ri) {
	return query(1, 0, _n - 1, le, ri); }
/*
int arr[10];

int main(void) {
#ifdef HOME
	freopen("secret.in", "r", stdin);
	freopen("secret.out", "w", stdout);
#endif
	int n; cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> arr[i]; }
	Init(n, arr);
	int m; cin >> m;
	while (m--) {
		int le, ri; cin >> le >> ri;
		int val = arr[le];
		for (int i = le + 1; i <= ri; ++i) {
			val = Secret(val, arr[i]); }
		cout << Query(le, ri) << " " << val << "\n"; }
	return 0; }	
*/
# Verdict Execution time Memory Grader output
1 Incorrect 160 ms 3036 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 826281507.
2 Incorrect 161 ms 3148 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 597766465.
3 Incorrect 161 ms 3232 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 539361598.
4 Incorrect 591 ms 5452 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 86507755.
5 Incorrect 587 ms 5452 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 358221838.
6 Incorrect 589 ms 5624 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 950134466.
7 Incorrect 593 ms 5624 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 537605146.
8 Incorrect 594 ms 5624 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 566467848.
9 Incorrect 595 ms 5672 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 962332426.
10 Incorrect 591 ms 5672 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 807273797.