#include <bits/stdc++.h>
using namespace std;
const int Z = 3e5+2;
int n, sz[Z] {-1}, sLink[Z], cnt[Z], cur = 2, p = 1;
map<char, int> c[Z];
string s;
int main() {
cin >> s; n = size(s);
s = '_' + s;
for(int i = 1; i <= n; ++i) {
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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
14292 KB |
Output is correct |
2 |
Correct |
7 ms |
14400 KB |
Output is correct |
3 |
Correct |
7 ms |
14292 KB |
Output is correct |
4 |
Correct |
7 ms |
14420 KB |
Output is correct |
5 |
Correct |
7 ms |
14292 KB |
Output is correct |
6 |
Correct |
7 ms |
14292 KB |
Output is correct |
7 |
Correct |
8 ms |
14292 KB |
Output is correct |
8 |
Correct |
8 ms |
14292 KB |
Output is correct |
9 |
Correct |
8 ms |
14292 KB |
Output is correct |
10 |
Correct |
7 ms |
14292 KB |
Output is correct |
11 |
Correct |
8 ms |
14344 KB |
Output is correct |
12 |
Correct |
8 ms |
14420 KB |
Output is correct |
13 |
Correct |
7 ms |
14420 KB |
Output is correct |
14 |
Correct |
8 ms |
14420 KB |
Output is correct |
15 |
Correct |
7 ms |
14420 KB |
Output is correct |
16 |
Correct |
7 ms |
14344 KB |
Output is correct |
17 |
Correct |
7 ms |
14364 KB |
Output is correct |
18 |
Correct |
7 ms |
14292 KB |
Output is correct |
19 |
Correct |
7 ms |
14396 KB |
Output is correct |
20 |
Correct |
8 ms |
14420 KB |
Output is correct |
21 |
Correct |
8 ms |
14420 KB |
Output is correct |
22 |
Correct |
7 ms |
14420 KB |
Output is correct |
23 |
Correct |
7 ms |
14420 KB |
Output is correct |
24 |
Correct |
7 ms |
14420 KB |
Output is correct |
25 |
Correct |
8 ms |
14348 KB |
Output is correct |
26 |
Correct |
8 ms |
14420 KB |
Output is correct |
27 |
Correct |
8 ms |
14420 KB |
Output is correct |
28 |
Correct |
7 ms |
14420 KB |
Output is correct |
29 |
Correct |
8 ms |
14420 KB |
Output is correct |
30 |
Correct |
7 ms |
14292 KB |
Output is correct |
31 |
Correct |
7 ms |
14420 KB |
Output is correct |
32 |
Correct |
7 ms |
14420 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
14420 KB |
Output is correct |
2 |
Correct |
8 ms |
14396 KB |
Output is correct |
3 |
Correct |
8 ms |
14440 KB |
Output is correct |
4 |
Correct |
7 ms |
14420 KB |
Output is correct |
5 |
Correct |
7 ms |
14420 KB |
Output is correct |
6 |
Correct |
8 ms |
14420 KB |
Output is correct |
7 |
Correct |
8 ms |
14476 KB |
Output is correct |
8 |
Correct |
7 ms |
14420 KB |
Output is correct |
9 |
Correct |
7 ms |
14420 KB |
Output is correct |
10 |
Correct |
8 ms |
14420 KB |
Output is correct |
11 |
Correct |
8 ms |
14368 KB |
Output is correct |
12 |
Correct |
8 ms |
14420 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
14932 KB |
Output is correct |
2 |
Correct |
8 ms |
14932 KB |
Output is correct |
3 |
Correct |
8 ms |
14932 KB |
Output is correct |
4 |
Correct |
8 ms |
14932 KB |
Output is correct |
5 |
Correct |
9 ms |
14932 KB |
Output is correct |
6 |
Correct |
8 ms |
14884 KB |
Output is correct |
7 |
Correct |
9 ms |
14908 KB |
Output is correct |
8 |
Correct |
8 ms |
14420 KB |
Output is correct |
9 |
Correct |
8 ms |
14352 KB |
Output is correct |
10 |
Correct |
8 ms |
14804 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
20276 KB |
Output is correct |
2 |
Correct |
19 ms |
20304 KB |
Output is correct |
3 |
Correct |
19 ms |
20304 KB |
Output is correct |
4 |
Correct |
19 ms |
20280 KB |
Output is correct |
5 |
Correct |
20 ms |
20372 KB |
Output is correct |
6 |
Correct |
20 ms |
18744 KB |
Output is correct |
7 |
Correct |
17 ms |
19420 KB |
Output is correct |
8 |
Correct |
14 ms |
14632 KB |
Output is correct |
9 |
Correct |
15 ms |
15824 KB |
Output is correct |
10 |
Correct |
19 ms |
19408 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
41 ms |
32264 KB |
Output is correct |
2 |
Correct |
43 ms |
32280 KB |
Output is correct |
3 |
Correct |
37 ms |
32172 KB |
Output is correct |
4 |
Correct |
36 ms |
32292 KB |
Output is correct |
5 |
Correct |
38 ms |
32200 KB |
Output is correct |
6 |
Correct |
39 ms |
30332 KB |
Output is correct |
7 |
Correct |
35 ms |
29288 KB |
Output is correct |
8 |
Correct |
28 ms |
15068 KB |
Output is correct |
9 |
Correct |
29 ms |
15064 KB |
Output is correct |
10 |
Correct |
33 ms |
29000 KB |
Output is correct |
11 |
Correct |
38 ms |
32216 KB |
Output is correct |
12 |
Correct |
31 ms |
16400 KB |
Output is correct |