QOJ.ac

QOJ

実行時間制限: 3 s メモリ制限: 1024 MB 満点: 100

#5000. 平衡跷跷板数组

統計

Bob 喜欢玩跷跷板。他认为如果跷跷板处于平衡状态会非常有趣。这意味着跷跷板既不向左倾斜也不向右倾斜。玩过跷跷板后,Bob 思考了一个与平衡跷跷板相关的问题。

令 $A = [a_1, a_2, \dots, a_m]$ 表示一个长度为 $m$ 的数组。Bob 认为如果存在一个 $1$ 到 $m$ 之间的整数 $k$,使得 $\sum_{i=1}^{m} (i - k)a_i = 0$,那么 $[a_1, a_2, \dots, a_m]$ 就是一个平衡跷跷板数组。

Bob 收到一个数组 $A = [a_1, a_2, \dots, a_n]$ 作为生日礼物,他很好奇其中是否存在某个非空子数组是平衡跷跷板数组。更正式地说,他想知道对于给定的某对 $(\ell, r)$(其中 $1 \le \ell \le r \le n$),$[a_\ell, a_{\ell+1}, \dots, a_r]$ 是否为一个平衡跷跷板数组。Bob 还发现数组中的元素会随时间发生变化,具体有以下两种变化:

  1. $a_\ell, a_{\ell+1}, \dots, a_r$ 增加 $x$。
  2. $a_\ell, a_{\ell+1}, \dots, a_r$ 变为 $x$。

为了方便起见,Bob 首先会给你数组 $A = [a_1, a_2, \dots, a_n]$。随后有 $q$ 次操作。每次操作属于以下三种类型之一:

  • $1 \ \ell \ r \ x$:表示将 $a_\ell, a_{\ell+1}, \dots, a_r$ 增加 $x$。
  • $2 \ \ell \ r \ x$:表示将 $a_\ell, a_{\ell+1}, \dots, a_r$ 修改为 $x$。
  • $3 \ \ell \ r$:表示 Bob 想知道子数组 $[a_\ell, a_{\ell+1}, \dots, a_r]$ 是否为一个平衡跷跷板数组。对于每个类型 3 的操作,你应该输出 “Yes” 或 “No”。

输入格式

第一行包含两个整数 $n$ 和 $q$。$n$ 是数组的长度,$q$ 是操作次数。第二行包含 $n$ 个整数 $a_i$,用于定义数组。接下来的 $q$ 行,每行描述一个操作。

输出格式

对于每个类型 3 的操作,请输出 “Yes” 或 “No”,以表示 $[a_\ell, a_{\ell+1}, \dots, a_r]$ 是否为一个平衡跷跷板数组。

数据范围

  • $1 \le n \le 100000$
  • $1 \le q \le 1200000$
  • $-1000 \le a_i \le 1000$
  • $-10000 \le x \le 10000$
  • 对于 $1 \le i \le n$,你可以假设在任何操作后 $|a_i| \le 1.5 \times 10^9$。
  • $1 \le \ell \le r \le n$

样例

输入 1

3 6
1 2 3
3 1 1
3 1 3
1 1 1 2
3 1 3
2 2 2 0
3 2 3

输出 1

Yes
No
Yes
Yes

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.