#P8932. [JRKSJ R7] Clock Paradox
[JRKSJ R7] Clock Paradox
Background

The problem setter one minute later stopped the problem setter at this moment from writing an interesting background story.
(The background image comes from Phigros artwork. If there is any infringement, please inform the problem setter.)
Problem Description
You are given a string , where .
There is a string , initially . You may perform several operations. In each operation, you can choose a substring of and insert it into any position of .
You want, after some operations, to make . Define as the minimum number of operations needed to satisfy this condition.
In addition, the string will undergo some changes. Specifically, there are modification operations. Each modification gives and , meaning set . Here means any lowercase letter, not the character whose ASCII code is .
You need to output the value of at the beginning and after each modification.
Input Format
The first line contains an integer , the number of modifications.
The second line contains a string consisting only of lowercase letters.
The next lines each contain an integer and a lowercase letter , representing one modification.
Output Format
There are lines. Each line contains an integer, the answer.
2
aabc
2 b
4 b
2
2
1
Hint
Idea: cyffff, Solution: cyffff, Code: cyffff, Data: cyffff
Clock Paradox - WyvernP (Insane12.6)
The input/output files of this problem are large. Please use appropriate I/O methods.
Hint
A string is a substring of string if and only if there exist such that .
Sample Explanation
Before all modifications, is computed as follows:
Initially, .
In the first operation, choose the substring of and insert it at the very beginning of . After the operation, .
In the second operation, choose the substring of and insert it after the -th character of . After the operation, , which meets the requirement.
After the first and second modifications, becomes and respectively. After these two modifications, is and respectively.
Constraints
This problem uses bundled testdata.
For of the testdata, , . It is guaranteed that consists only of lowercase letters, and is a single lowercase letter.
Translated by ChatGPT 5