社区讨论

申请加强数据

P3368【模板】树状数组 2参与者 4已保存回复 8

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
8 条
当前快照
1 份
快照标识符
@mhjl8l9g
此快照首次捕获于
2025/11/04 04:23
4 个月前
此快照最后确认于
2025/11/04 04:23
4 个月前
查看原帖
RT
此题可以用直接模拟的方法拿到足足70分
mycode:
CPP
#include<bits/stdc++.h>
using namespace std;
const int N=5e5+5;
int n,m;
int x,y,k;
int a[N],tag;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i=1;i<=n;i++) cin >> a[i];
    for (int i=1;i<=m;i++) {
        cin >> tag;
        if (tag==1) {
            cin >> x >> y >> k;
            for (int i=x;i<=y;i++) a[i]+=k;
        } else {
            cin >> x;
            cout << a[x] << endl;
        }
    }
    return 0;
}

回复

8 条回复,欢迎继续交流。

正在加载回复...