#pragma GCC optimize "-O3"
#include <bits/stdc++.h>
using namespace std;
const int N = 3000*100+7;
long long h1[N],h2[N];
long long p[N];
long long hashcode1(int l,int r){
return h1[r]-h1[l-1]*p[r-l+1];
}
long long hashcode2(int l,int r){
return h2[r]-h2[l-1]*p[r-l+1];
}
int main()
{
string s;
cin>>s;
int n = s.length();
p[0] = 1;
for(int i = 1;i<=n;i++) p[i] = p[i-1]*259;
string srev = s;
reverse(srev.begin(),srev.end());
for(int i = 1;i<=n;i++){
h1[i] = h1[i-1]*259+s[i-1];
h2[i] = h2[i-1]*259+srev[i-1];
}
unordered_map<long long,int> mp;
int ans = 0;
for(int i = 1;i<=n;i++){
for(int j = i;j<=n;j++){
long long x = hashcode1(i,j);
int jj = n-i+1;
int ii = n-j+1;
long long y = hashcode2(ii,jj);
if(x == y){
mp[x]++;
ans = max(ans,(j-i+1)*mp[x]);
}
}
}
cout<<ans<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
488 KB |
Output is correct |
3 |
Correct |
3 ms |
548 KB |
Output is correct |
4 |
Correct |
2 ms |
556 KB |
Output is correct |
5 |
Correct |
2 ms |
556 KB |
Output is correct |
6 |
Correct |
3 ms |
556 KB |
Output is correct |
7 |
Correct |
2 ms |
556 KB |
Output is correct |
8 |
Correct |
2 ms |
556 KB |
Output is correct |
9 |
Correct |
3 ms |
556 KB |
Output is correct |
10 |
Correct |
3 ms |
556 KB |
Output is correct |
11 |
Correct |
2 ms |
556 KB |
Output is correct |
12 |
Correct |
3 ms |
556 KB |
Output is correct |
13 |
Correct |
2 ms |
556 KB |
Output is correct |
14 |
Correct |
2 ms |
556 KB |
Output is correct |
15 |
Correct |
4 ms |
600 KB |
Output is correct |
16 |
Correct |
3 ms |
600 KB |
Output is correct |
17 |
Correct |
3 ms |
600 KB |
Output is correct |
18 |
Correct |
3 ms |
600 KB |
Output is correct |
19 |
Correct |
3 ms |
600 KB |
Output is correct |
20 |
Correct |
2 ms |
600 KB |
Output is correct |
21 |
Correct |
2 ms |
676 KB |
Output is correct |
22 |
Correct |
3 ms |
680 KB |
Output is correct |
23 |
Correct |
2 ms |
680 KB |
Output is correct |
24 |
Correct |
4 ms |
680 KB |
Output is correct |
25 |
Correct |
3 ms |
680 KB |
Output is correct |
26 |
Correct |
2 ms |
680 KB |
Output is correct |
27 |
Correct |
2 ms |
724 KB |
Output is correct |
28 |
Correct |
3 ms |
724 KB |
Output is correct |
29 |
Correct |
2 ms |
724 KB |
Output is correct |
30 |
Correct |
2 ms |
724 KB |
Output is correct |
31 |
Correct |
2 ms |
724 KB |
Output is correct |
32 |
Correct |
2 ms |
724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
724 KB |
Output is correct |
2 |
Correct |
10 ms |
724 KB |
Output is correct |
3 |
Correct |
28 ms |
724 KB |
Output is correct |
4 |
Correct |
5 ms |
724 KB |
Output is correct |
5 |
Correct |
19 ms |
724 KB |
Output is correct |
6 |
Correct |
21 ms |
724 KB |
Output is correct |
7 |
Correct |
4 ms |
724 KB |
Output is correct |
8 |
Correct |
12 ms |
724 KB |
Output is correct |
9 |
Correct |
5 ms |
724 KB |
Output is correct |
10 |
Correct |
4 ms |
724 KB |
Output is correct |
11 |
Correct |
6 ms |
724 KB |
Output is correct |
12 |
Correct |
7 ms |
724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1075 ms |
1252 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1074 ms |
7152 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1070 ms |
21232 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |