Submission #133318

# Submission time Handle Problem Language Result Execution time Memory
133318 2019-07-20T12:01:46 Z egorlifar Secret (JOI14_secret) C++17
0 / 100
589 ms 4600 KB
#include "secret.h"
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>

using namespace std;
template<typename T1, typename T2>inline void chkmin(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void chkmax(T1 &x, T2 y) { if (x < y) x = y; }
#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define left left224
#define right right224
#define next next224
#define rank rank224
#define prev prev224
#define y1 y1224
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
#define files(FILENAME) read(FILENAME), write(FILENAME)
#define pb push_back
#define mp make_pair
const int MAXN = 1001;


int n;
int val[MAXN][10];
int val1[MAXN][10];


void Init(int N, int A[]) {
	n = N;
	for (int i = 0; i < n; i++) {
		val[i][0] = A[i];
		val1[i][0] = A[i];
	}
	for (int k = 1; k <= 9; k++) {
		for (int i = 0; i < n; i++) {
			int f = i % (1 << k);
			if (i - f == i - i % (1 << (k - 1))) {
				val[i][k] = val[i][k - 1];
			} else {
				val[i][k] = Secret(val[i - 1][k], val[i][0]);
			}
		}
		for (int i = n - 1; i >= 0; i--) {
			if (i % (1 << k) == 0) {
				val1[i][k] = val[min(n - 1, i + (1 << k) - 1)][k];
				continue;
			}
			if (i == n - 1 || (i % (1 << k)) == (1 << k) - 1) {
				val1[i][k] = val1[i][0];
				continue;
			}
			int g = i % (1 << k);
			int ft = (1 << k) - g - 1;
			int g1 = i % (1 << (k - 1));
			int ft1 = (1 << (k - 1)) - g1 - 1;
			int h = i + ft;
			int h1 = i + ft1;
			if (h == h1) {
				val1[i][k] = val1[i][k - 1];
			} else {
				val1[i][k] = Secret(val1[i][0], val1[i + 1][k]);
			}
		}
	}
}


int Query(int L, int R) {
	int l = L;
	int r = R;
	int g = 1;
	int f = 0;
	while (g * 2 <= r - l + 1) {
		g <<= 1;
		f++;
	}
	if (l % g == 0) {
		return val1[l][f];
	}
	int ff = l - l % g + g;
	assert(ff <= r);
	//assert(ff + g > r);
	return Secret(val1[l][f], val[r][f]);
}
# Verdict Execution time Memory Grader output
1 Incorrect 159 ms 2600 KB Wrong Answer: Query(113, 206) - expected : 536899947, actual : 64440048.
2 Incorrect 160 ms 2428 KB Wrong Answer: Query(30, 75) - expected : 635142465, actual : 827473017.
3 Incorrect 161 ms 2536 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 75868656.
4 Incorrect 589 ms 4476 KB Wrong Answer: Query(193, 615) - expected : 280593123, actual : 832217619.
5 Incorrect 584 ms 4404 KB Wrong Answer: Query(263, 292) - expected : 653448456, actual : 238590042.
6 Incorrect 589 ms 4508 KB Wrong Answer: Query(200, 208) - expected : 277813445, actual : 10934295.
7 Incorrect 587 ms 4600 KB Wrong Answer: Query(0, 993) - expected : 589312106, actual : 95595635.
8 Incorrect 589 ms 4484 KB Wrong Answer: Query(0, 839) - expected : 428261768, actual : 231973200.
9 Incorrect 588 ms 4488 KB Wrong Answer: Query(0, 930) - expected : 424418475, actual : 412627009.
10 Incorrect 588 ms 4424 KB Wrong Answer: Query(0, 893) - expected : 611994251, actual : 607431565.