#B. 线段树 关于时间

    Type: Default 1000ms 256MiB

线段树 关于时间

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Description

nn 个整数 a1,a2,,ana_1, a_2, \dots, a_n 组成一个序列。有一个存储三元组的列表,开始时该列表为空。 有 mm 个操作,这些操作分为两种:

  • 1 L R x\texttt{1 L R x}\:\:(L,R,x)(L, R, x) 加入列表中。
  • 2 L R    \texttt{2 L R}\;\;\quadaL+aL+1++aRa_L + a_{L+1} + \cdots + a_R

每执行完一个操作,就读取一遍列表,对于其中的每一组 (L,R,x)(L, R, x)aL,aL+1,,aRa_L, a_{L+1},\ldots,a_R 都加上 xx(这不算做操作)。

Format

Input

第一行一个整数 nn,表示序列长度。 第二行 nn 个整数。 第三行一个整数 mm,表示操作数。 然后 mm 行,先输入一个数 DDDD1122

  • DD11,读入 33 个整数 L,R,xL, R, x
  • DD22,读入 22 个整数 L,RL, R

Output

对于每个操作 2 L R\texttt{2 L R},输出一行,一个整数,aL+aL+1++aRa_L + a_{L+1} + \cdots + a_R

Samples

3
1 2 3
4
1 1 3 1
2 1 1
1 2 3 2
2 2 3
2
15
列表 输出 aia_i
开始 1 2 3
1 1 3 1 1 3 1<
读取列表 1 3 1 2 3 4
2 1 1 2
读取列表 3 4 5
1 2 3 2 1 3 1 2 3 2<
读取列表 1 3 1 2 3 2 4 7 8
2 2 3 1 3 1 2 3 2 15
读取列表 1 3 1 2 3 2 5 10 11

Limitation

对于 60% 60 \% 的数据,暴力可过。 对于 100% 100 \% 的数据,1n,m105, 1 \le n, m \le 10^5, 1LRn, 1 \le L \le R \le n, 1ai104 1 \le a_i \le 10^4 , 104x104 -10^4 \le x \le 10^4

暑期模拟赛 一

Not Attended
Status
Done
Rule
IOI
Problem
5
Start at
2024-7-11 8:30
End at
2024-7-11 12:00
Duration
3.5 hour(s)
Host
Partic.
9