답안 #916283

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
916283 2024-01-25T15:16:56 Z vjudge1 Palindromic Partitions (CEOI17_palindromic) Python 3
컴파일 오류
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: unmatched ')'