#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<int,int> pi ;
#define if1(x) for(int i =1 ;i<=x;i++)
#define if0(x) for(int i = 0;i<x;i++)
#define jf0(x) for(int j = 0;j<x;j++)
#define jf1(x) for(int j = 1;j<=x;j++)
#define pb push_back
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
const int N = 1e5+10;
void solve(){
int m,n;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t=1;
cin>>t;
while (t--)
{
solve();
}
return 0;
}
const int N = 2e5;
int w[N];
struct Node {
int l, r;
int sum;
int add;
} tr[4*N];
void pushup(int u) {
tr[u].sum = tr[u<<1].sum + tr[u<<1|1].sum;
}
void pushdown(int u) {
if (tr[u].add == 0) return;
auto &root = tr[u];
auto &left = tr[u<<1];
auto &right = tr[u<<1|1];
left.sum += (left.r - left.l + 1) * root.add;
left.add += root.add;
right.sum += (right.r - right.l + 1) * root.add;
right.add += root.add;
root.add = 0;
}
void build(int u, int l, int r) {
tr[u] = {l, r};
if (l == r) {
tr[u].sum = w[l];
return;
}
int mid = (l + r) >> 1;
build(u<<1, l, mid);
build(u<<1|1, mid+1, r);
pushup(u);
}
int query(int u, int l, int r) {
if (l <= tr[u].l && r >= tr[u].r) {
return tr[u].sum;
}
pushdown(u);
int mid = (tr[u].l + tr[u].r) >> 1;
int v = 0;
if (l <= mid) {
v = query(u<<1, l, r);
}
if (r > mid) {
v += query(u<<1|1, l, r);
}
return v;
}
void modify(int u, int l, int r, int v) {
if (l <= tr[u].l && r >= tr[u].r) {
tr[u].sum += (tr[u].r - tr[u].l + 1) * v;
tr[u].add += v;
} else {
pushdown(u);
int mid = (tr[u].l + tr[u].r) >> 1;
if (l <= mid) {
modify(u<<1, l, r, v);
}
if (r > mid) {
modify(u<<1|1, l, r, v);
}
pushup(u);
}
}
在这里插入代码片