#C8624. K-Palindrome Challenge

    ID: 52627 Type: Default 1000ms 256MiB

K-Palindrome Challenge

K-Palindrome Challenge

Given a string \( s \) and an integer \( k \), determine whether it is possible to transform \( s \) into a palindrome by removing at most \( k \) characters.

The key observation is that the minimum number of removals required to convert \( s \) into a palindrome is \(|s| - LPS(s)\), where \( LPS(s) \) is the length of the longest palindromic subsequence in \( s \). Hence, the condition becomes:

\( |s| - LPS(s) \le k \)

If the above condition holds, output True; otherwise, output False.

inputFormat

The input is read from standard input (stdin) and consists of two lines:

  • The first line contains a non-empty string \( s \).
  • The second line contains an integer \( k \) indicating the maximum number of characters that can be removed.

outputFormat

Output to standard output (stdout) a single line containing True if \( s \) can be transformed into a palindrome by removing at most \( k \) characters, otherwise False.

## sample
abcdeca
2
True

</p>