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:
- Make v__i-th array element equal to x__i. In other words, perform the assignment a__v__i = x__i.
- Increase each array element by y__i. In other words, perform n assignments a__i = a__i + y__i (1 ≤ i ≤ n).
- 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.
谢列亚得到了一个由 n 个整数组成的数组:a1,a2,…,an。谢列亚是个活跃的男孩,因此他现在要执行 m 个操作。每个操作有以下三种形式之一:
- 将第 vi 个数组元素赋值为 xi。即执行赋值操作:avi=xi。
- 将数组中每个元素增加 yi。即执行 n 次赋值操作:ai=ai+yi(其中 1≤i≤n)。
- 在纸上写下第 qi 个数组元素。即输出元素 aqi。
请帮助谢列亚完成所有这些操作。
输入格式
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).
第一行包含两个整数 n、m(1 ≤ n, m ≤ 105)。第二行包含 n 个用空格分隔的整数 a1, a2, ..., an(1 ≤ ai ≤ 109)——原始数组。
接下来 m 行描述操作,其中第 i 行描述第 i 个操作。第 i 行的第一个数是整数 ti(1 ≤ ti ≤ 3),表示操作类型。若 ti=1,则其后跟两个整数 vi 和 xi(1 ≤ vi ≤ n, 1 ≤ xi ≤ 109);若 ti=2,则其后跟一个整数 yi(1 ≤ yi ≤ 104);若 ti=3,则其后跟一个整数 qi(1 ≤ qi ≤ 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.
对于每个第三类操作,输出值 aqi。请按照输入中对应查询出现的顺序输出这些值。
输入输出样例
输入#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测评打分。不知道怎么写?