33OJ
登录 注册

#P13976. 数列分块入门 1

数列分块入门 1

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 single-point value queries.

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 value of ara_r (ll and cc are ignored).

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 0 1 0
0 1 2 2
1 0 2 0
2
5

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≤3000001 \leq n \leq 300000, −263≤ai,c,ans≤263−1-2^{63} \leq a_i, c, \mathrm{ans} \leq 2^{63}-1.

For all testdata, 1≤n≤3000001 \leq n \leq 300000 and −263≤ai,c,ans≤263−1-2^{63} \leq a_i, c, \mathrm{ans} \leq 2^{63}-1. opt∈{0,1}\mathrm{opt} \in \{0,1\}, 1≤l≤r≤n1 \leq l \leq r \leq n. After each operation every aia_i satisfies −263≤ai≤263−1-2^{63} \leq a_i \leq 2^{63}-1.

Translated by QwenWork