something
1.cmp时,return 1表示a在前面,return 0表示1在后面
2.
ll tem=x; x=y; y=tem-a/b*y;
3.vector实现平衡树:
opt=read();shu=read(); if(opt==1)v.insert(upper_bound(v.begin(),v.end(),shu),shu); if(opt==2)v.erase(lower_bound(v.begin(),v.end(),shu)); if(opt==3)printf("%d\n",lower_bound(v.begin(),v.end(),shu)-v.begin()+1); if(opt==4)printf("%d\n",v[shu-1]); if(opt==5)printf("%d\n",*--lower_bound(v.begin(),v.end(),shu)); if(opt==6)printf("%d\n",*upper_bound(v.begin(),v.end(),shu));
// 1插入
2删除
3x的位置
4x位置的数
5前驱
6后继
4.数据离散化(有重复)
for(int i=1;i<=n;i++){ls[i]=read();sl[i]=ls[i];} sort(ls+1,ls+n+1); int len=unique(ls+1,ls+n+1)-ls-1; for(int i=1;i<=n;i++) sl[i]=lower_bound(ls+1,ls+1+len,sl[i])-ls;