版本比较
板子
正文
增加 4 行删除 4 行
53 行未改动545556575858596061626364656566676869707172737374757677372 行未改动全部展开450451452453454454455456457458138 行未改动全部展开53 行未改动int main(){ scanf("%lld%lld",&n,&m); long long root = 1; //根结点编号 cnt = 1; //总结点数量 cnt = 1; //总结点数量 for(long long i = 1; i <= n; i++) { long long x; scanf("%lld",&x); update(root, 1, n, i, i, x); }
for(long long i = 1; i <= m; i++) { long long op, x, y, val; scanf("%lld%lld%lld",&op,&x,&y); if(op == 1) { scanf("%lld",&val); update(root, 1, n, x, y, val); update(root, 1, n, x, y, val); } else{ printf("%lld\n",query(root,1,n,x,y)); }372 行未改动全部展开 return 0;}
```# 重链剖分/树链剖分 # 重链剖分/树链剖分```cpp#include<bits/stdc++.h>using namespace std;const int MX=1e5+10;int n,m,r,p;int input[MX]={0};int siz[MX]={0};int fath[MX]={0};int top[MX]={0};int dfn[MX]={0};int son[MX]={0};int high[MX]={0};int w[MX]={0};138 行未改动全部展开