Submission #1076533

# Submission time Handle Problem Language Result Execution time Memory
1076533 2024-08-26T14:34:44 Z surgutti Brperm (RMI20_brperm) C++14
0 / 100
257 ms 172060 KB
#include "brperm.h"

typedef long long LL;

const LL mod = 1e9 + 9;
const LL base = 2137;

const int L = 20;
const int N = 1 << L;

LL pw[N + 1], h1[L][N], h2[L][N];

void init(int n, const char s[]) {
	pw[0] = 1;
	for (int i = 1; i <= N; i++)
		pw[i] = pw[i - 1] * base % mod;
	
	for (int h = 0; h < L; h++)
		for (int i = n - 1; i >= 0; i--)
			h1[h][i] = (s[i] + h1[h][i + 1] * pw[1 << h]) % mod;

	for (int i = 0; i < n; i++)
		h2[0][i] = s[i];
	
	for (int h = 0; h + 1 < L; h++)
		for (int i = 0; i < n; i++)
			h2[h + 1][i] = (h2[h][i] + pw[(1 << (L - 2 - h))] * h2[h][i + (1 << h)]) % mod;
}

int query(int i, int k) {
	int l = L - 1 - k;
	LL h = (h1[l][i] - h1[l][i + (1 << k)] * pw[1 << (L - 1)] % mod + mod) % mod;
	return h == h2[k][i];
}
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 9304 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 9304 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 257 ms 172060 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 9304 KB Output isn't correct
2 Halted 0 ms 0 KB -