# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
916284 | 2024-01-25T15:17:23 Z | vjudge1 | Palindromic Partitions (CEOI17_palindromic) | Python 2 | 0 ms | 0 KB |
def is_palindrome(s): return s == s[::-1] def max_palindromic_partition(s): n = len(s) dp = [0] * n for i in range(n): max_partition = 0 for j in range(i+1): if is_palindrome(s[j:i+1]): max_partition = max(max_partition, 1 + (dp[j-1] if j > 0 else 0)) dp[i] = max_partition return dp[n-1] # Input t = int(input()) for _ in range(t): s = input().strip() # Output print(max_palindromic_partition(s)))