33OJ
登录 注册

#P13977. 数列分块入门 2

数列分块入门 2

Background

The constraints of the testdata in Luogu's "Introduction to Sequence Block Decomposition" series differ from those of the original problems.

Problem Description

You are given a sequence of length nn and nn operations. The operations involve range addition and queries for the number of elements smaller than a value xx in a range.

Input Format

The first line contains one integer nn.

The second line contains nn integers, where the ii-th integer is aia_i, separated by spaces.

Then nn lines follow, each containing a query. Each line contains four integers opt\mathrm{opt}, ll, rr, cc, separated by spaces.

If opt=0\mathrm{opt} = 0, it means that cc is added to every number in [l,r][l, r].

If opt=1\mathrm{opt} = 1, it means that you should query the number of elements in [l,r][l, r] that are smaller than x=c2x = c^2.

Output Format

For each query, output one integer on a single line giving the answer.

4
1 2 2 3
0 1 3 1
1 1 3 2
1 1 4 1
1 2 3 2
3
0
2

Hint

Subtasks

Subtask 1 (40 points): 1≤n≤500001 \leq n \leq 50000, −231≤ai,c,ans≤231−1-2^{31} \leq a_i, c, \mathrm{ans} \leq 2^{31}-1.

Subtask 2 (60 points): 1≤n≤2000001 \leq n \leq 200000, −231≤ai,c,ans≤231−1-2^{31} \leq a_i, c, \mathrm{ans} \leq 2^{31}-1.

For all testdata, 1≤n≤2000001 \leq n \leq 200000 and −231≤ai,c,ans≤231−1-2^{31} \leq a_i, c, \mathrm{ans} \leq 2^{31}-1. opt∈{0,1}\mathrm{opt} \in \{0,1\}. The testdata do not guarantee that every aia_i satisfies −231≤ai≤231−1-2^{31} \leq a_i \leq 2^{31}-1 after each operation. 1≤l≤r≤n1 \leq l \leq r \leq n.

Translated by QwenWork