Submission #554988

# Submission time Handle Problem Language Result Execution time Memory
554988 2022-04-29T19:31:50 Z sidon Palindromes (APIO14_palindrome) C++17
100 / 100
38 ms 33500 KB
#include <bits/stdc++.h>
using namespace std;

const int Z = 3e5+2;

int sz[Z] = {-1}, sLink[Z], cnt[Z], cur = 2, p = 1;
map<int, int> c[Z];

int n, __s[Z] {-1}, *s = __s + 1;
string _s;

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> _s;
	n = _s.size();

	for(int i = 0; i < n; ++i) {
		s[i] = _s[i] - 'a';
		for(; s[i-sz[p]-1] != s[i]; p = sLink[p]);

		if(!c[p][s[i]]) {
			int &v = (sLink[cur] = sLink[p]);
			for(; s[i-sz[v]-1] != s[i]; v = sLink[v]);
			v = max(1, c[v][s[i]]);

			sz[cur] = sz[p] + 2;
			c[p][s[i]] = cur++;
		}
		++cnt[p = c[p][s[i]]];
	}

	long long res {};

	for(int u = cur; u--; ) {
		res = max(res, 1LL * cnt[u] * sz[u]);
		cnt[sLink[u]] += cnt[u];
	}

	cout << res;
}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 14420 KB Output is correct
2 Correct 7 ms 14420 KB Output is correct
3 Correct 10 ms 14420 KB Output is correct
4 Correct 7 ms 14420 KB Output is correct
5 Correct 7 ms 14420 KB Output is correct
6 Correct 7 ms 14420 KB Output is correct
7 Correct 7 ms 14436 KB Output is correct
8 Correct 7 ms 14420 KB Output is correct
9 Correct 7 ms 14420 KB Output is correct
10 Correct 7 ms 14420 KB Output is correct
11 Correct 8 ms 14420 KB Output is correct
12 Correct 7 ms 14420 KB Output is correct
13 Correct 7 ms 14360 KB Output is correct
14 Correct 7 ms 14420 KB Output is correct
15 Correct 7 ms 14420 KB Output is correct
16 Correct 7 ms 14424 KB Output is correct
17 Correct 7 ms 14420 KB Output is correct
18 Correct 8 ms 14352 KB Output is correct
19 Correct 7 ms 14420 KB Output is correct
20 Correct 7 ms 14420 KB Output is correct
21 Correct 7 ms 14420 KB Output is correct
22 Correct 8 ms 14420 KB Output is correct
23 Correct 10 ms 14420 KB Output is correct
24 Correct 8 ms 14420 KB Output is correct
25 Correct 8 ms 14372 KB Output is correct
26 Correct 8 ms 14420 KB Output is correct
27 Correct 7 ms 14420 KB Output is correct
28 Correct 7 ms 14420 KB Output is correct
29 Correct 9 ms 14420 KB Output is correct
30 Correct 7 ms 14420 KB Output is correct
31 Correct 8 ms 14420 KB Output is correct
32 Correct 7 ms 14420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 14420 KB Output is correct
2 Correct 7 ms 14504 KB Output is correct
3 Correct 8 ms 14420 KB Output is correct
4 Correct 11 ms 14420 KB Output is correct
5 Correct 8 ms 14420 KB Output is correct
6 Correct 7 ms 14420 KB Output is correct
7 Correct 8 ms 14420 KB Output is correct
8 Correct 7 ms 14420 KB Output is correct
9 Correct 8 ms 14420 KB Output is correct
10 Correct 8 ms 14420 KB Output is correct
11 Correct 7 ms 14420 KB Output is correct
12 Correct 7 ms 14420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14968 KB Output is correct
2 Correct 8 ms 15060 KB Output is correct
3 Correct 8 ms 15060 KB Output is correct
4 Correct 8 ms 15060 KB Output is correct
5 Correct 8 ms 15060 KB Output is correct
6 Correct 9 ms 15060 KB Output is correct
7 Correct 9 ms 15060 KB Output is correct
8 Correct 9 ms 14420 KB Output is correct
9 Correct 9 ms 14420 KB Output is correct
10 Correct 8 ms 14820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 20740 KB Output is correct
2 Correct 17 ms 20784 KB Output is correct
3 Correct 17 ms 20756 KB Output is correct
4 Correct 20 ms 20720 KB Output is correct
5 Correct 16 ms 20692 KB Output is correct
6 Correct 16 ms 19164 KB Output is correct
7 Correct 16 ms 19796 KB Output is correct
8 Correct 13 ms 15024 KB Output is correct
9 Correct 14 ms 16284 KB Output is correct
10 Correct 16 ms 19820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 33400 KB Output is correct
2 Correct 36 ms 33488 KB Output is correct
3 Correct 38 ms 33500 KB Output is correct
4 Correct 35 ms 33500 KB Output is correct
5 Correct 33 ms 33388 KB Output is correct
6 Correct 33 ms 31508 KB Output is correct
7 Correct 32 ms 30508 KB Output is correct
8 Correct 27 ms 16000 KB Output is correct
9 Correct 25 ms 15972 KB Output is correct
10 Correct 29 ms 30300 KB Output is correct
11 Correct 35 ms 33384 KB Output is correct
12 Correct 25 ms 17500 KB Output is correct