Submission #1296860

#TimeUsernameProblemLanguageResultExecution timeMemory
1296860mdobricPalinilap (COI16_palinilap)C++20
0 / 100
5 ms832 KiB
#include <bits/stdc++.h>
using namespace std;

const int maxn = 105,  baza = 29;
const long long MOD = 998244353;
int n;
string s, s2;
int dp[maxn][maxn];
long long poc, ans;
string znak = "abcdefghijklmnopqrstuvwxyz";

int main (void){
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> s;
	n = s.size();
	s2 = s;
	for (int slovo = 0; slovo < 26; slovo++){
		for (int pos = 0; pos < n; pos++){
			s[pos] = znak[slovo];
			poc = 0;
			for (int i = 0; i < n; i++){
				for (int j = 0; j <= i; j++){
					if (i == j) dp[i][j] = 1, poc++;
					else if (s[i] == s[j] and (i == j + 1 or dp[i - 1][j + 1] == 1)) dp[i][j] = 1, poc++;
				}
			}
			s = s2;
			ans = max(ans, poc);
		}
	}
	cout << ans << "\n";

	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...