Home => ProblemSet => 3.2-39:[SP11470]TTM - To the moon
Problem1971--3.2-39:[SP11470]TTM - To the moon

1971: 3.2-39:[SP11470]TTM - To the moon

Time Limit: 1 Sec  Memory Limit: 128 MB  Submit: 0  Solved: 0
[ Submit ] [ Status ] [ Creator: ][ 参考程序 ]

Description

一个长度为 N 的数组 {A},4 种操作 :
  • C l r d:区间 [l,r] 中的数都加 d ,同时当前的时间戳加 1。
  • Q l r:查询当前时间戳区间 [l,r] 中所有数的和 。
  • H l r t:查询时间戳 t 区间 [l,r] 的和 。
  • B t:将当前时间戳置为 t 。
所有操作均合法 。
ps:刚开始时时间戳为 0
输入格式,一行 N 和 M,接下来 M 行每行一个操作
输出格式:对每个查询输出一行表示答案
数据保证:1≤N,M≤105,∣Ai∣≤109,1≤l≤r≤N,∣d∣≤104。在刚开始没有进行操作的情况下时间戳为 0,且保证 B 操作不会访问到未来的时间戳。

Input

n m
A1 A2 ... An 
... (here following the m operations. )

Output

... (for each query, simply print the result. )

Sample Input Copy

10 5
1 2 3 4 5 6 7 8 9 10
Q 4 4
Q 1 10
Q 2 4
C 3 6 3
Q 2 4

Sample Output Copy

4
55
9
15

HINT

样例二:
输入:
2 4
0 0
C 1 1 1
C 2 2 -1
Q 1 2
H 1 2 1
输出:
0
1


Source/Category