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;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
string s;
cin >> s;
int n = s.size();
int res = 0;
for(int i=0;i<n;i++){
char base = s[i];
for(char j='a';j<='z';j++){
s[i] = j;
int dp[n][n];
memset(dp,0,sizeof(dp));
for(int k=0;k<n;k++){
dp[k][k] = 1;
if(k+1 < n && s[k] == s[k+1]){
dp[k][k+1] = 1;
}
}
for(int k=0;k<n-1;k++){
for(int l=1;k+l<n-1;l++){
if(dp[l][l+k] && s[l-1] == s[l+k+1]){
dp[l-1][l+k+1] = 1;
}
}
}
int curr = 0;
for(int k=0;k<n;k++){
for(int l=0;l<n;l++){
curr += dp[k][l];
}
}
res = max(res,curr);
}
s[i] = base;
}
cout << res << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |