This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define ll long long
string S;
bool dp[1005][1005];
map<string, int> mp;
void solve(){
ifstream in("input.txt");
ofstream out("output.txt");
cin>>S;
int N = S.length();
for(int i = 0; i < N; i++){
dp[i][i] = 1;
mp[S.substr(i, 1)]++;
}
for(int i = 0; i < N-1; i++){
if(S[i] == S[i+1]){
dp[i][i+1] = 1;
mp[S.substr(i, 2)]++;
}
}
for(int i = 3; i <= N; i++){
for(int j = 0; j <= N-i; j++){
int end = j+i-1;
if(dp[j+1][end-1] && S[j] == S[end]){
dp[j][end] = 1;
mp[S.substr(j, i)]++;
}
}
}
int ans = 0;
for(auto a : mp){
ans = max(ans, (int)(a.first.length())*a.second);
}
cout<<ans<<endl;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |