#P5640. 【CSGRound2】逐梦者的初心
【CSGRound2】逐梦者的初心
Description
You are given a string of length .
There are operations, and it is guaranteed that .
You also have a string , which is empty at the beginning.
There are two types of operations.
The first type of operation:
Append one character to the end of string .
The second type of operation:
Prepend one character to the beginning of string .
After each operation, you need to output how many satisfy the following condition:
For , we have .
String indices start from 1. denotes the length of .
Input Format
The first line contains two positive integers .
The second line contains positive integers separated by spaces. The -th integer represents .
Next, there are lines, each containing two numbers . means appending a character to the end of , and means prepending a character to the beginning of .
Output Format
Output lines. Each line contains one non-negative integer representing the answer after the -th operation.
10 3
1 2 3 1 2 3 2 3 2 3
0 1
1 2
0 3
0
1
1
Hint
Note: This problem uses bundled tests. You can get the score of a subtask only after you pass all test points of that subtask.
For all testdata, $n \leq 10^6,m \leq 3.3333 \times 10^4,|\sum|\leq10^3,S_i \in [1,|\sum|]$. ( denotes the alphabet)
subtask 1 : .
subtask 2 : .
subtask 3 : .
subtask 4 : no special constraints.
Sample Explanation:
After the first operation, .
When , , so the answer is 0.
After the second operation, .
When , .
When , , , so the answer is 1.
After the third operation, .
When , .
When , .
When , , so the answer is 1.
Translated by ChatGPT 5
京公网安备 11011102002149号