← 返回 citadel 的题目列表Minimum Changes for Palindromic Length-k Substrings
类型:online_judge
Given a password string s of length n and an integer k, one operation replaces any character with any lowercase English letter.
Find the minimum number of replacements needed so that every contiguous substring of length exactly k is a palindrome.
This formulation interprets “every k characters” as every sliding contiguous substring of length k. A version that partitions the string into disjoint blocks of size k is a different problem.
Input Format
n k
s
1 <= n <= 2 * 10^5
1 <= k <= n
s contains lowercase English letters only.
Output Format
Print the minimum number of replacements.
Example
Input:
7 3
abacaba
Output:
1
Example
Input
7 3
abacaba
Output
1