当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3971:Play With Sequence

题目描述
When the girl was solving GSSX, a serious of tough problems about data structure on SPOJ, something intriguing once again comes to GYZ's mind. That is, for a changing sequences, how to count how many elements in a specific range efficiently.

Without any beneficial idea, as usual, GYZ asks her friend, CLJ for help. But this time, unfortunately, CLJ is playing a gal-game at present, does not have sparse time.

So now , it is your turn...

Cause the original problem is not as easy as first glance, let's examine a simplified one:

you are given a sequence A[1], A[2],..., A[N]. On this sequence you have to apply M operations: Add all the elements whose value are in range [l, r] with d or, ask for a query how many element are in range [l, r].

输入解释
There are only one test case, Process until the end of the file. The first line of each case contains two numbers, N, M, described as above. And then start from the second line, have N numbers described the sequence's initial value.

( 1≤ N ≤ 250,000, M ≤ 50,000), |A[i]|≤ 1,000,000,000 .)

The following M lines described the operation:

C l r d: Add all the element whose value are in range [l, r] with d. (Redeclare: Not its Position! .. ) Q l r: ask for a query how many elements, whose value are in range [l, r].

( l ≤ r, |l|,|r|,|d|≤ 1,000,000,000 )

We guarantee every elements are suits 32-integer, and will not cause overflow, even during the running-time. (.. but still be careful ;) Besides, all the test-data are generated randomly.

输出解释
For each query, print the result. Example
输入样例
10 10
10 4 -5 8 8 3 0 -2 4 7
C -9 8 2
C -4 10 -3
C -10 0 5
Q -9 -1
C -9 -5 8
C -7 4 3
Q -2 7
C -10 -3 2
C -4 -1 -6
Q 7 10
输出样例
1
10
4

提示
(In the first example, after the two operations, the sequences are become to, {-4, -3, -2, -1, 0, 11, 12, 13, 14, 15}, 
so there are no elements whose value are in range [1, 10]. ) 
来自杭电HDUOJ的附加信息
Recommend chenyongfu

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-3971

最后修改于 2020-10-25T23:08:53+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
10000/5000MS(Java/Others) 65768/65768K(Java/Others)