正文
增加 15 行删除 15 行
64 行未改动6566676869707172736 行未改动80818283848586878823 行未改动11211311411511611711811912089 行未改动210211212213214215216217218219220221222223114 行未改动全部展开3383393403413423433443453464 行未改动3513523533543553563573583596 行未改动3663673683693703713723733744 行未改动37938038138238338438538638737 行未改动4254264274284294304314324334344354364374384394404414424434444454464474484494504514524 行未改动64 行未改动{int res=1,mul=a;while(b){if(b&1)res*=mul%M,res%=M;mul=(mul*mul)%M;b>>=1;}6 行未改动```cppstruct dsu{vector<size_t> pa,size;explicit dsu(size_t size_):pa(size_),size(size_,1){iota(pa.begin(),pa.end(),0);}23 行未改动### ST 表模板```cpptemplate <typename T,typename Cmp=less<T>()>class Sprase_Table{protected:vector<vector<T> > ST;89 行未改动_x-=lowbit(_x);}rt res;}};```### 单源最短路模板(图的模板全部基于邻接表,~~果断抛弃邻接矩阵和链式前向星~~)#### 1.(Dijkstra,pb_ds)```cppconst int inf=INT_MAX;114 行未改动全部展开_tree[Right(_pos)]+=_lazy[_pos]*(_r-_mid);_lazy[_pos]=0;}}void build(int _l,int _r,int _root){if(_l==_r){4 行未改动build(_l,_mid,Left(_root));build(_mid+1,_r,Right(_root));_tree[_root]=_tree[Left(_root)]+_tree[Right(_root)];}void update(int _ul,int _ur,T _val,int _l,int _r,int _pos){if(_ul<=_l && _ur>=_r){6 行未改动if(_ul<=_mid) update(_ul,_ur,_val,_l,_mid,Left(_pos));if(_ur>_mid) update(_ul,_ur,_val,_mid+1,_r,Right(_pos));_tree[_pos]=_tree[Left(_pos)]+_tree[Right(_pos)];}T sum(int _ql,int _qr,int _l,int _r,int _pos){if(_ql<=_l && _r<=_qr)rt _tree[_pos];4 行未改动if(_qr>_mid) _res+=sum(_ql,_qr,_mid+1,_r,Right(_pos));rt _res;}public:explicit Segment_Tree<T>(vector<T> v){_tree.resize((n<<2)+5,0);_lazy.resize((n<<2)+5,0);37 行未改动{case 1:RBT.insert((x<<20)+i);break;case 2:RBT.erase(RBT.lower_bound((x<<20)));break;case 3:write(RBT.order_of_key(x<<20)+1);puts("");break;case 4:write((*RBT.find_by_order(x-1))>>20);puts("");break;case 5:write((*--RBT.lower_bound(x<<20))>>20);puts("");break;case 6:write((*RBT.upper_bound((x<<20)+n))>>20);puts("");break;4 行未改动64 行未改动6566676869707172736 行未改动80818283848586878823 行未改动11211311411511611711811912089 行未改动210211212213214215216217218219220221222223114 行未改动全部展开3383393403413423433443453464 行未改动3513523533543553563573583596 行未改动3663673683693703713723733744 行未改动37938038138238338438538638737 行未改动4254264274284294304314324334344354364374384394404414424434444454464474484494504514524 行未改动64 行未改动{int res=1,mul=a;while(b){if(b&1)res*=mul%M,res%=M;mul=(mul*mul)%M;b>>=1;}6 行未改动```cppstruct dsu{vector<size_t> pa,size;explicit dsu(size_t size_):pa(size_),size(size_,1){iota(pa.begin(),pa.end(),0);}23 行未改动### ST 表模板```cpptemplate <typename T,typename Cmp=less<T>()>class Sprase_Table{protected:vector<vector<T> > ST;89 行未改动_x-=lowbit(_x);}rt res;}};```### 单源最短路模板(图的模板全部基于邻接表,~~果断抛弃邻接矩阵和链式前向星~~)#### 1.(Dijkstra,pb_ds)```cppconst int inf=INT_MAX;114 行未改动全部展开_tree[Right(_pos)]+=_lazy[_pos]*(_r-_mid);_lazy[_pos]=0;}}void build(int _l,int _r,int _root){if(_l==_r){4 行未改动build(_l,_mid,Left(_root));build(_mid+1,_r,Right(_root));_tree[_root]=_tree[Left(_root)]+_tree[Right(_root)];}void update(int _ul,int _ur,T _val,int _l,int _r,int _pos){if(_ul<=_l && _ur>=_r){6 行未改动if(_ul<=_mid) update(_ul,_ur,_val,_l,_mid,Left(_pos));if(_ur>_mid) update(_ul,_ur,_val,_mid+1,_r,Right(_pos));_tree[_pos]=_tree[Left(_pos)]+_tree[Right(_pos)];}T sum(int _ql,int _qr,int _l,int _r,int _pos){if(_ql<=_l && _r<=_qr)rt _tree[_pos];4 行未改动if(_qr>_mid) _res+=sum(_ql,_qr,_mid+1,_r,Right(_pos));rt _res;}public:explicit Segment_Tree<T>(vector<T> v){_tree.resize((n<<2)+5,0);_lazy.resize((n<<2)+5,0);37 行未改动{case 1:RBT.insert((x<<20)+i);break;case 2:RBT.erase(RBT.lower_bound((x<<20)));break;case 3:write(RBT.order_of_key(x<<20)+1);puts("");break;case 4:write((*RBT.find_by_order(x-1))>>20);puts("");break;case 5:write((*--RBT.lower_bound(x<<20))>>20);puts("");break;case 6:write((*RBT.upper_bound((x<<20)+n))>>20);puts("");break;4 行未改动