QOJ.ac

QOJ

حد الوقت: 1.0 s حد الذاكرة: 1024 MB مجموع النقاط: 100 قابلة للهجوم ✓

#9543. 好的划分

الإحصائيات

Lawliet 有一个长度为 $n$ 的数字序列,记作 $a_1, a_2, \dots, a_n$,他想确定有多少个好的划分。

如果一个划分大小 $k$ 满足 $1 \le k \le n$,且将序列 $a$ 按该大小划分后,得到的每个子序列都是非递减的,则称该划分大小 $k$ 为一个好的划分大小。划分方法如下:

  • 序列 $a$ 被划分为 $\lceil \frac{n}{k} \rceil$ 个部分。
  • 对于第 $i$ 个部分($1 \le i \le \lceil \frac{n}{k} \rceil - 1$),元素为 $a_{(i-1) \times k + 1}, a_{(i-1) \times k + 2}, \dots, a_{i \times k}$。
  • 对于第 $\lceil \frac{n}{k} \rceil$ 个部分,元素为 $a_{(\lceil \frac{n}{k} \rceil - 1) \times k + 1}, \dots, a_n$。注意,最后一部分的长度可能小于 $k$。

Lawliet 觉得这个问题太简单了,所以他将进行 $q$ 次修改。每次修改提供两个正整数 $p$ 和 $v$,表示将 $a_p$ 的值修改为 $v$。

你的任务是帮助 Lawliet 计算在进行任何修改之前以及每次修改之后,好的划分大小的数量。

输入格式

第一行包含一个整数 $T$ ($1 \le T \le 10$),表示测试用例的数量。

对于每个测试用例,第一行包含两个整数 $n$ ($1 \le n \le 2 \cdot 10^5$) 和 $q$ ($1 \le q \le 2 \cdot 10^5$),分别表示序列的长度和修改次数。

第二行包含 $n$ 个整数,表示序列 $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 2 \cdot 10^9$)。

接下来的 $q$ 行,每行包含两个整数 $p$ ($1 \le p \le n$) 和 $v$ ($1 \le v \le 2 \cdot 10^9$),表示序列中第 $p$ 个位置的元素将被修改为 $v$。

保证所有测试用例中 $n$ 的总和与 $q$ 的总和分别不超过 $2 \cdot 10^5$。

输出格式

对于每个测试用例,输出 $q + 1$ 行,分别表示在任何修改之前以及每次修改之后,好的划分大小的数量。

样例

输入 1

1
5 2
4 3 2 6 1
2 5
3 5

输出 1

1
2
3

说明

最初,唯一好的划分大小是 $k = 1$。

第一次修改后,序列变为 $[4, 5, 2, 6, 1]$。$k = 1$ 和 $k = 2$ 都是好的划分大小。

第二次修改后,序列变为 $[4, 5, 5, 6, 1]$。好的划分大小为 $k = 1, k = 2$ 和 $k = 4$。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.