05 2022 档案
线段树维护区间最值操作与区间历史最值
摘要:宏定义 #define pl p<<1\texttt{\#define pl p<<1}#define pl p<<1:节点 ppp 的左儿子。 #define pr p<<1|1\texttt{\#define pr p<<1|1}#define pr p<<1|1:节点 ppp 的右儿子。 常量
线段树的合并与分裂
摘要:宏定义 #define pl a[p].tl\texttt{\#define pl a[p].tl}#define pl a[p].tl:节点 ppp 的左儿子。 #define pr a[p].tr\texttt{\#define pr a[p].tr}#define pr a[p].tr:节点
可持久化线段树
摘要:宏定义 #define pl a[p].tl\texttt{\#define pl a[p].tl}#define pl a[p].tl:节点 ppp 的左儿子。 #define pr a[p].tr\texttt{\#define pr a[p].tr}#define pr a[p].tr:节点
康托展开
摘要:求一个全排列的排名。 公式 ans=1+∑i=1nai×(n−i)!ans=1+\sum_{i=1}^na_i\times(n-i)!ans=1+i=1∑nai×(n−i)! 代码 需要用到树状数组。 ll c[N],ji[N]; void add(int x,int v){ for(;x<=n
P8317 [FOI2021] 幸运区间
摘要:Link\text{Link}Link 自己供的第一道题。 题意 给出 nnn 个数列,编号为 0∼n−10\sim n-10∼n−1,每个数列有 ddd 个正整数。 对于一段区间 [l,r][l,r][l,r],从序列 lll 到 rrr 中的数字中选出不超过 kkk 个数字,称之为幸运数字。若存