#P15080. [ICPC 2024 Chengdu R] Good Partitions
[ICPC 2024 Chengdu R] Good Partitions
题目描述
Lawliet has a sequence of numbers of length , denoted as , and he wants to determine how many good partitions exist.
A partition size is considered a good partition size if it satisfies and, after dividing the sequence into parts by partition size, each resulting sub-sequence is non-decreasing. The partitioning method is as follows:
- The sequence is divided into parts.
- For the -th part (), the elements are $a_{(i - 1) \times k + 1}, a_{(i - 1) \times k + 2}, \ldots, a_{i \times k}$.
- For the -th part, the elements are $a_{(\lceil \frac{n}{k} \rceil - 1) \times k + 1}, \ldots, a_n$. Note that the length of the last part may be less than .
Lawliet finds this problem too simple, so he will make modifications. Each modification provides two positive integers and , indicating that the value of will be changed to .
Your task is to help Lawliet calculate the number of good partition sizes before any modifications and after each modification.
输入格式
The first line contains an integer (), representing the number of test cases.
For each test case, the first line contains two integers () and (), representing the length of the sequence and the number of modifications.
The second line contains integers, representing the sequence ().
The following lines each contain two integers () and (), indicating that the element at the -th position in the sequence will be modified to .
It is guaranteed that the sum of and the sum of over all test cases do not exceed , respectively.
输出格式
For each test case, output lines, representing the number of good partition sizes before any modifications and after each modification.
1
5 2
4 3 2 6 1
2 5
3 5
1
2
3
提示
Initially, the only good partition size is .
After the first modification, the sequence becomes . Both and are good partition sizes.
After the second modification, the sequence becomes . The good partition sizes are , , and .