propitious @ 2024-02-26 21:00:55
#include<bits/stdc++.h>
using namespace std;
map<int,map<int,int> > a;
int main()
{
int n,m,x,i,j,k;
cin>>n>>m;
for(int i=1;i<=m;i++)
{
cin>>x>>i>>j;
if(x==1){
cin>>k;
if(k==0) a[i][j]=0;
else a[i][j]+=k;
}
else
cout<<a[i][j]<<endl;
}
}
by chao_ti_jie @ 2024-02-26 21:10:56
for循环的i和输入的冲突了
by chao_ti_jie @ 2024-02-26 21:11:35
https://www.luogu.com.cn/paste/xt6e9ycb
by Wzl111 @ 2024-03-18 20:47:13
#include<bits/stdc++.h>
using namespace std;
int n,q;
int read(){
int x=0;
int f=1;
char c=getchar();
while(!isdigit(c)){
if(c=='-'){
f=-1;
}
c=getchar();
}
while(isdigit(c)){
x=x*10+(c&15);
c=getchar();
}
return x*f;
}
map<long long,long long>a[100001];
int main(){
n=read();
q=read();
while(q--){
int x;
x=read();
if(x==1){
int i,j,k;
i=read();
j=read();
k=read();
a[i][j]=k;
}else{
int i,j;
i=read();
j=read();
printf("%d\n",a[i][j]);
}
}
return 0;
}
by Wzl111 @ 2024-03-18 20:48:33
O(q)的复杂度