Submission #243618

# Submission time Handle Problem Language Result Execution time Memory
243618 2020-07-01T12:27:31 Z islingr Palindromes (APIO14_palindrome) C++14
100 / 100
34 ms 35068 KB
#include <iostream>
using namespace std;

const int N = 5 << 16, A = 26;
int link[N], len[N], nxt[N][A], occ[N], cnt = 2, lst = 2;
char s[N];

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	cin >> s;
	len[1] = -1; link[1] = 1;
	len[2] = -0; link[2] = 1;
	for (int i = 0; s[i]; ++i) {
		int cur = lst, a = s[i] - 'a';
		while (s[i - len[cur] - 1] != s[i]) cur = link[cur];
		int &tmp = nxt[cur][a];
		if (!tmp) {
			tmp = ++cnt;
			len[tmp] = len[cur] + 2;
			if (cur != 1) {
				cur = link[cur];
				while (s[i - len[cur] - 1] != s[i]) cur = link[cur];
				link[tmp] = nxt[cur][a];
			} else link[tmp] = 2;
		}
		lst = tmp; ++occ[lst];
	}
	long long ans = 0;
	for (int i = cnt; i > 2; --i) {
		occ[link[i]] += occ[i];
		ans = max(ans, 1ll * occ[i] * len[i]);
	}
	cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 4 ms 384 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 4 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 4 ms 384 KB Output is correct
31 Correct 5 ms 512 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 5 ms 512 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 6 ms 512 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
6 Correct 5 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 512 KB Output is correct
9 Correct 4 ms 512 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1536 KB Output is correct
2 Correct 5 ms 1536 KB Output is correct
3 Correct 6 ms 1536 KB Output is correct
4 Correct 5 ms 1536 KB Output is correct
5 Correct 6 ms 1536 KB Output is correct
6 Correct 5 ms 1536 KB Output is correct
7 Correct 5 ms 1536 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 1152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 11904 KB Output is correct
2 Correct 14 ms 11904 KB Output is correct
3 Correct 15 ms 11904 KB Output is correct
4 Correct 14 ms 11904 KB Output is correct
5 Correct 15 ms 11904 KB Output is correct
6 Correct 12 ms 8832 KB Output is correct
7 Correct 13 ms 10112 KB Output is correct
8 Correct 6 ms 768 KB Output is correct
9 Correct 9 ms 3200 KB Output is correct
10 Correct 14 ms 10240 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 35064 KB Output is correct
2 Correct 32 ms 35064 KB Output is correct
3 Correct 34 ms 34936 KB Output is correct
4 Correct 34 ms 35068 KB Output is correct
5 Correct 32 ms 34944 KB Output is correct
6 Correct 30 ms 31232 KB Output is correct
7 Correct 32 ms 29312 KB Output is correct
8 Correct 9 ms 1152 KB Output is correct
9 Correct 10 ms 1152 KB Output is correct
10 Correct 27 ms 28792 KB Output is correct
11 Correct 32 ms 35064 KB Output is correct
12 Correct 12 ms 4224 KB Output is correct