제출 #616884

#제출 시각아이디문제언어결과실행 시간메모리
616884HappyPacManPalinilap (COI16_palinilap)C++14
17 / 100
1092 ms524288 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...