atcoder#ABC278D. [ABC278D] All Assign Point Add

[ABC278D] All Assign Point Add

Score : 400400 points

Problem Statement

You are given a sequence A=(A1,A2,,AN)A = (A_1, A_2, \dots, A_N) of length NN.

Given QQ queries, process all of them in order. The qq-th (1qQ)(1\leq q\leq Q) query is in one of the following three formats, which represents the following queries:

  • 1 xq1\ x _ q: assign xqx_q to every element of AA.
  • 2 iq xq2\ i _ q\ x _ q: add xqx_q to AiqA _ {i _ q}.
  • 3 iq3\ i _ q: print the value of AiqA _ {i _ q}.

Constraints

  • 1N2×1051 \leq N \leq 2\times10^5
  • 1Q2×1051 \leq Q \leq 2\times10^5
  • 0Ai109 (1iN)0 \leq A _ i \leq 10^9\ (1\leq i\leq N)
  • If the qq-th (1qQ)(1\leq q\leq Q) query is in the second or third format, 1iqN1 \leq i _ q \leq N.
  • If the qq-th (1qQ)(1\leq q\leq Q) query is in the first or second format, 0xq1090 \leq x _ q \leq 10^9.
  • There exists a query in the third format.
  • All values in the input are integers.

Input

The input is given from Standard Input in the following format:

NN

A1A_1 A2A_2 \dots ANA_N

QQ

query1\operatorname{query}_1

query2\operatorname{query}_2

\vdots

queryQ\operatorname{query}_Q

Here, queryq\operatorname{query}_q denotes the qq-th query, which is in one of following formats: 1 x, 2 i x, and 3 i.

Output

Print XX lines, where XX is the number of qq's (1qQ)(1\leq q\leq Q) such that queryq\operatorname{query}_q is in the third format. The jj-th (1jX)(1\leq j\leq X) line should contain the answer to the jj-th such query.

5
3 1 4 1 5
6
3 2
2 3 4
3 3
1 1
2 3 4
3 3
1
8
5

Initially, A=(3,1,4,1,5)A=(3,1,4,1,5). The queries are processed as follows:

  • A2=1A_2=1, so print 11.
  • Add 44 to A3A_3, making A=(3,1,8,1,5)A=(3,1,8,1,5).
  • A3=8A_3=8, so print 88.
  • Assign 11 to every element of AA, making A=(1,1,1,1,1)A=(1,1,1,1,1).
  • Add 44 to A3A_3, making A=(1,1,5,1,1)A=(1,1,5,1,1).
  • A3=5A_3=5, so print 55.
1
1000000000
8
2 1 1000000000
2 1 1000000000
2 1 1000000000
2 1 1000000000
2 1 1000000000
2 1 1000000000
2 1 1000000000
3 1
8000000000

Note that the elements of AA may not fit into a 3232-bit integer type.

10
1 8 4 15 7 5 7 5 8 0
20
2 7 0
3 7
3 8
1 7
3 3
2 4 4
2 4 9
2 10 5
1 10
2 4 2
1 10
2 3 1
2 8 11
2 3 14
2 1 9
3 8
3 8
3 1
2 6 5
3 7
7
5
7
21
21
19
10