CF315B.Sereja and Array

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Sereja has got an array, consisting of n integers, _a_1, _a_2, ..., a__n. Sereja is an active boy, so he is now going to complete m operations. Each operation will have one of the three forms:

  1. Make v__i-th array element equal to x__i. In other words, perform the assignment a__v__i = x__i.
  2. Increase each array element by y__i. In other words, perform n assignments a__i = a__i + y__i (1 ≤ i ≤ n).
  3. Take a piece of paper and write out the q__i-th array element. That is, the element a__q__i.

Help Sereja, complete all his operations.

谢列亚得到了一个由 nn 个整数组成的数组:a1,a2,…,ana_1, a_2, \dots, a_n。谢列亚是个活跃的男孩,因此他现在要执行 mm 个操作。每个操作有以下三种形式之一:

  1. 将第 viv_i 个数组元素赋值为 xix_i。即执行赋值操作:avi=xia_{v_i} = x_i。
  2. 将数组中每个元素增加 yiy_i。即执行 nn 次赋值操作:ai=ai+yia_i = a_i + y_i(其中 1≤i≤n1 \le i \le n)。
  3. 在纸上写下第 qiq_i 个数组元素。即输出元素 aqia_{q_i}。

请帮助谢列亚完成所有这些操作。

输入格式

The first line contains integers n, m (1 ≤ n, m ≤ 105). The second line contains n space-separated integers _a_1, _a_2, ..., a__n (1 ≤ a__i ≤ 109) — the original array.

Next m lines describe operations, the i-th line describes the i-th operation. The first number in the i-th line is integer t__i (1 ≤ t__i ≤ 3) that represents the operation type. If t__i = 1, then it is followed by two integers v__i and x__i, (1 ≤ v__i ≤ n, 1 ≤ x__i ≤ 109). If t__i = 2, then it is followed by integer y__i (1 ≤ y__i ≤ 104). And if t__i = 3, then it is followed by integer q__i (1 ≤ q__i ≤ n).

第一行包含两个整数 nn、mm(1 ≤ n, m ≤ 1051 \leq n, m \leq 10^5)。第二行包含 nn 个用空格分隔的整数 a1, a2, ..., ana_1, a_2, ..., a_n(1 ≤ ai ≤ 1091 \leq a_i \leq 10^9)——原始数组。

接下来 mm 行描述操作,其中第 ii 行描述第 ii 个操作。第 ii 行的第一个数是整数 tit_i(1 ≤ ti ≤ 31 \leq t_i \leq 3),表示操作类型。若 ti=1t_i = 1,则其后跟两个整数 viv_i 和 xix_i(1 ≤ vi ≤ n1 \leq v_i \leq n, 1 ≤ xi ≤ 1091 \leq x_i \leq 10^9);若 ti=2t_i = 2,则其后跟一个整数 yiy_i(1 ≤ yi ≤ 1041 \leq y_i \leq 10^4);若 ti=3t_i = 3,则其后跟一个整数 qiq_i(1 ≤ qi ≤ n1 \leq q_i \leq n)。

输出格式

For each third type operation print value a__q__i. Print the values in the order, in which the corresponding queries follow in the input.

对于每个第三类操作,输出值 aqia_{q_i}。请按照输入中对应查询出现的顺序输出这些值。

输入输出样例

  • 输入#1

    10 11
    1 2 3 4 5 6 7 8 9 10
    3 2
    3 9
    2 10
    3 1
    3 10
    1 1 10
    2 10
    2 10
    3 1
    3 10
    3 9

    输出#1

    2
    9
    11
    20
    30
    40
    39

输入解题思路,AI测评打分。不知道怎么写?

首页