rt, 蒟蒻太菜了调不出来
by Midnight_szx @ 2023-05-14 18:45:46
@[Midnight_szx](/user/801371) 过了
```cpp
#include<iostream>
#include<algorithm>
#include<cstdio>
#define lowbit(x) ((x) & - (x))
using namespace std;
int t1[2050][2050], t2[2050][2050], t3[2050][2050], t4[2050][2050];
int n, m;
void update(int x, int y, int k) {
for(int i = x; i <= n; i += lowbit(i))
for(int j = y; j <= m; j += lowbit(j)) {
t1[i][j] = t1[i][j] + k;
t2[i][j] = t2[i][j] + x * k;
t3[i][j] = t3[i][j] + y * k;
t4[i][j] = t4[i][j] + x * y * k;
}
}
int query(int x, int y) {
int ans = 0;
for(int i = x; i ; i -= lowbit(i))
for(int j = y; j ; j -= lowbit(j))
ans = ans + (x + 1) * (y + 1) * t1[i][j] - (y + 1) * t2[i][j] - (x + 1) * t3[i][j] + t4[i][j];
return ans;
}
signed main() {
char op[2];
scanf("%s", op);
cin>>n>>m;
while(scanf("%s", op) != EOF) {
int a, b, c, d, cxk;
cin>>a>>b>>c>>d;
if(op[0] == 'L') {
cin>>cxk;
update(c + 1, d + 1, cxk);
update(a, d + 1, cxk * (-1));
update(c + 1, b, cxk * (-1));
update(a, b, cxk);
}
if(op[0] == 'k')
cout<<query(c, d) + query(a - 1, b - 1) - query(a - 1, d) - query(c, b - 1)<<'\n';
}
return 0;
}
```
by __er @ 2023-05-14 19:10:47
@[Midnight_szx](/user/801371) 快谢谢__er
by MinCat @ 2023-05-14 19:11:33
@[__er](/user/713955)
请问这样写和我原来的写法有什么区别吗?
by Midnight_szx @ 2023-05-14 19:12:52
@[Midnight_szx](/user/801371) 此题卡 `long long`,你用了 `scanf` 还解绑
by __er @ 2023-05-14 19:14:53
写法没问题
by __er @ 2023-05-14 19:15:13
@[__er](/user/713955)
知道了,谢谢!
by Midnight_szx @ 2023-05-15 21:20:27