#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
const ll mod = 998244353;
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define faster ios::sync_with_stdio(false);cin.tie(nullptr)
int main() {
string s;
cin >> s;
ll N=s.size();
if(N>10000) return 0;
vector<ll> A(N+1),B(N+1);
A[0]=0;
B[N]=0;
ll k=1;
rep(i,N) A[i+1]=(A[i]+(s[i]-'a'+1)*k)%mod,k=k*100%mod;
k=1;
for(ll i=N-1;i>=0;i--) B[i]=(B[i+1]+(s[i]-'a'+1)*k)%mod,k=k*100%mod;
vector<ll> inv(N);
inv[0]=1;
rep(i,N-1) inv[i+1]=inv[i]*828542813%mod;
unordered_map<ll,ll> M;
ll ans=0;
vector<vector<ll>> dpA(N,vector<ll>(N)),dpB(N,vector<ll>(N));
rep(i,N) rep(j,N) dpA[i][j]=(A[j+1]-A[i]+mod)*(inv[i])%mod;
rep(i,N) rep(j,N) dpB[i][j]=(B[i]-B[j+1]+mod)*(inv[N-j-1])%mod;
for(ll i=0;i<N;i++){
for(ll j=i;j<N;j++){
ll x=dpA[i][j];
ll y=dpB[i][j];
if(x==y){
M[x]+=j-i+1;
ans=max(ans,M[x]);
}
}
}
cout << ans << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
272 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
300 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
0 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
0 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
0 ms |
340 KB |
Output is correct |
27 |
Correct |
1 ms |
468 KB |
Output is correct |
28 |
Correct |
0 ms |
340 KB |
Output is correct |
29 |
Correct |
0 ms |
468 KB |
Output is correct |
30 |
Correct |
1 ms |
468 KB |
Output is correct |
31 |
Correct |
1 ms |
340 KB |
Output is correct |
32 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
15956 KB |
Output is correct |
2 |
Correct |
14 ms |
15828 KB |
Output is correct |
3 |
Correct |
30 ms |
15956 KB |
Output is correct |
4 |
Correct |
12 ms |
15956 KB |
Output is correct |
5 |
Correct |
28 ms |
15900 KB |
Output is correct |
6 |
Correct |
25 ms |
15828 KB |
Output is correct |
7 |
Correct |
12 ms |
15956 KB |
Output is correct |
8 |
Correct |
20 ms |
15876 KB |
Output is correct |
9 |
Correct |
12 ms |
16064 KB |
Output is correct |
10 |
Correct |
11 ms |
15900 KB |
Output is correct |
11 |
Correct |
11 ms |
15828 KB |
Output is correct |
12 |
Correct |
12 ms |
16092 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
51 ms |
131072 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
868 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |