Submission #916284

# Submission time Handle Problem Language Result Execution time Memory
916284 2024-01-25T15:17:23 Z vjudge1 Palindromic Partitions (CEOI17_palindromic) Python 2
Compilation error
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)))

Compilation message

File "palindromic.py", line 20
    print(max_palindromic_partition(s)))
                                       ^
SyntaxError: invalid syntax