字符串
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
字符串
题目描述
定义:字符串s
为一个c-好串
(c 为一个字符)时,必须满足:
- 当 ,
- 当, 的左半部分为全为 ,右半部分为一个
(c+1)-好串
或者 的右半部分为全为 ,左半部分为一个(c+1)-好串
其中 代表 字符串 的长度。
举个例子:当 时, 是一个 a-好串
现在,给你一个字符串 ( ),问最少替换多少个字符,使其为一个 a-好串
。
输入格式
第一行一个正整数 ,表示字符串长度。
第二行给定字符串 ,保证只有小写字母,且 。
输出格式
输出一个正整数,表示最少替换字符数。
样例
Input 1
8
bbdcaaaa
Output 1
0
Input 2
8
asdfghjk
Output 2
7
Input 3
8
ceaaaabb
Output 3
4
Constraints
子任务 | 特殊性质 | 分值 | |
---|---|---|---|
N/A | |||
中只有小写字母 | |||
中只有小写字母 | |||
N/A |
暴力、部分分训练
- Status
- Done
- Rule
- IOI
- Problem
- 8
- Start at
- 2024-10-6 14:00
- End at
- 2024-10-6 18:00
- Duration
- 4 hour(s)
- Host
- Partic.
- 4