D - All Assign Point Add
创始人
2024-02-01 16:53:08
0次

D - All Assign Point Add

Score : 400400 points

Problem Statement

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

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

  • 1\ x _ q1 xq​: assign x_qxq​ to every element of AA.
  • 2\ i _ q\ x _ q2 iq​ xq​: add x_qxq​ to A _ {i _ q}Aiq​​.
  • 3\ i _ q3 iq​: print the value of A _ {i _ q}Aiq​​.

Constraints

  • 1 \leq N \leq 2\times10^51≤N≤2×105
  • 1 \leq Q \leq 2\times10^51≤Q≤2×105
  • 0 \leq A _ i \leq 10^9\ (1\leq i\leq N)0≤Ai​≤109 (1≤i≤N)
  • If the qq-th (1\leq q\leq Q)(1≤q≤Q) query is in the second or third format, 1 \leq i _ q \leq N1≤iq​≤N.
  • If the qq-th (1\leq q\leq Q)(1≤q≤Q) query is in the first or second format, 0 \leq x _ q \leq 10^90≤xq​≤109.
  • 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
A_1A1​ A_2A2​ \dots… A_NAN​
QQ
\operatorname{query}_1query1​
\operatorname{query}_2query2​
\vdots⋮
\operatorname{query}_QqueryQ​

Here, \operatorname{query}_qqueryq​ 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 (1\leq q\leq Q)(1≤q≤Q) such that \operatorname{query}_qqueryq​ is in the third format. The jj-th (1\leq j\leq X)(1≤j≤X) line should contain the answer to the jj-th such query.


Sample Input 1 Copy

Copy

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

Sample Output 1 Copy

Copy

1
8
5

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

  • A_2=1A2​=1, so print 11.
  • Add 44 to A_3A3​, making A=(3,1,8,1,5)A=(3,1,8,1,5).
  • A_3=8A3​=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 A_3A3​, making A=(1,1,5,1,1)A=(1,1,5,1,1).
  • A_3=5A3​=5, so print 55.

Sample Input 2 Copy

Copy

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

Sample Output 2 Copy

Copy

8000000000

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


Sample Input 3 Copy

Copy

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

Sample Output 3 Copy

Copy

7
5
7
21
21
19
10

#include #include 
#include 
using namespace std;const int N = 2e5 + 5;
map> m;
long long tag=0,ti=0;int main()
{int n;cin >> n;for (int i = 1; i <= n; i++){long long e;cin >>e;m[i].first = 0;m[i].second = e;}int q;cin >> q;int t;for (int i = 1; i <= q; i++){cin >> t;if (t == 1){cin >> tag;ti = i;//tag最近的更新操作是第ti次}else if (t == 2){unsigned long long o, x;cin >> o >> x;if(m[o].first> p;if (m[p].first < ti){cout << tag << endl;}else{cout << tag + m[p].second << endl;}}}}

相关内容

热门资讯

前端-session、jwt 目录:   (1)session (2&#x...
linux入门---制作进度条 了解缓冲区 我们首先来看看下面的操作: 我们首先创建了一个文件并在这个文件里面添加了...
关于测试,我发现了哪些新大陆 关于测试 平常也只是听说过一些关于测试的术语,但并没有使用过测试工具。偶然看到编程老师...
前缀和与对数器与二分法 1. 前缀和 假设有一个数组,我们想大量频繁的去访问L到R这个区间的和,...
nodejs:本地安装nvm实... 一、背景-使用不同版本node的原因 vue3+ts、nuxt3版本,node...
JAVA集合知识整理 Java集合知识整理 HashMap相关 HashMap的底层数据结构:jdk1.8之...
无刷直流电机介绍及单片机控制实... 无刷直流电机介绍及单片机控制实例前言基本概念优势与劣势使用寿命基本结构使用单片机控制实例电子调速器&...
fwdiary(2) dp2 1.传纸条  AcWing 275. 传纸条 - AcWing 走两条路,走一条最大的...
常用的DOS命令 常用的DOS命令 DOS(Disk Operating System,磁...
<C++> 类和对象(下) 1.const成员函数将const修饰的“成员函数”称之为const成员函数,cons...