#P10810. 【MX-S2-T1】 变
【MX-S2-T1】 变
Background
Original problem link: https://oier.team/problems/S2A。
Problem Description
You are given a string consisting only of lowercase English letters.
In each operation, you may choose any character in and change it to any lowercase English letter.
You may perform at most operations in any order to minimize the length of the strict period of . Of course, you may also choose to perform no operations.
Output the smallest possible length of the strict period of after all operations.
A string is called a strict period of if and only if can be constructed by repeating some number of times.
For example,
maiis a strict period ofmaimai, anddxis a strict period ofdx. Butovis not a strict period ofovo。
Input Format
The first line contains a non-negative integer .
The second line contains a string , consisting only of lowercase English letters.
Output Format
Output one integer on a single line, representing the answer.
1
test
4
3
test
1
3
apollo
3
Hint
[Sample Explanation #1]
It can be proven that with at most one operation, the strict period length is at least .
[Sample Explanation #2]
With operations, you can change test into ssss, and the strict period length is .
[Constraints]
This problem uses bundled testdata.
- Subtask 0 (17 pts): , .
- Subtask 1 (14 pts): , .
- Subtask 2 (16 pts): , .
- Subtask 3 (32 pts): .
- Subtask 4 (21 pts): no special constraints.
For all testdata, it is guaranteed that , and contains only lowercase English letters.
2024.7.28: A new Hack testdata set has been added.
Translated by ChatGPT 5