链接:https://atcoder.jp/contests/abc278/tasks/abc278_d
题目大意:op1:把数组的元素全部变为x
op2:把b[x]加上y
op3:输出b[x]
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,m,s,p;
map<int,bool >mp;
int b[200005];
signed main()
{
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++)cin>>b[i];
cin>>m;
while(m--)
{
int op,x,y;
cin>>op;
if(op==1)
{
p=1;
cin>>x;
s=x;
mp.clear();//这步是关键,政哥教的
}
else if(op==2)
{
cin>>x>>y;
if(p&&mp[x]==0)
{
b[x]=s+y;
mp[x]=1;
}
else b[x]+=y;
}
else if(op==3)
{
cin>>x;
//cout<<b[x]<<"#"<<s<<"*\n";
if(p&&mp[x]==0)
{
b[x]=s;
mp[s]=1;
}
cout<<b[x]<<'\n';
}
}
}