Submission #616884

# Submission time Handle Problem Language Result Execution time Memory
616884 2022-08-01T07:26:35 Z HappyPacMan Palinilap (COI16_palinilap) C++14
17 / 100
1000 ms 524288 KB
#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
1 Correct 22 ms 332 KB Output is correct
2 Correct 62 ms 340 KB Output is correct
3 Correct 39 ms 336 KB Output is correct
4 Correct 39 ms 348 KB Output is correct
5 Correct 39 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1092 ms 98120 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 225 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -