随笔分类 - template
算法模板
摘要:posted on 2022-01-25 18:52:13 | under 模板 | source typedef long long LL; const int P = 998244353; template <int N, int M, class T = LL> struct matrix {
阅读全文
摘要:posted on 2022-09-17 15:59:26 | under 模板 | source code LL mod(LL x,LL m){return(x%m+m)%m;} LL exgcd(LL a,LL b,LL c,LL& x,LL& y){ if(!b) return x=c/a,y
阅读全文
摘要:posted on 2022-10-23 13:50:24 | under 模板 | source problem 给定一个二维平面,多次询问 $x\in[l_x,r_x],y\in[l_y,r_y]$ 的点有多少个。 solution 1(静态+在线):可持久化线段树 将 $x\in[1,l]$
阅读全文
摘要:posted on 2021-11-27 22:37:04 | under 模板 | source sto crxis 注:不是 tarjan void crxis(int u){ for(int i=g.head[u];i;i=g.nxt[i]){ int v=g[i].v; if(dep[v]=
阅读全文
摘要:posted on 2022-07-20 18:59:16 | under 模板 | source 0x00 模板(P3806) 给定 $n,k$ 和一棵树,计算 $$\sum\limits_{i,j\leq n}[{\tt dist}(i,j)=k]$$ 即树上距离为 $k$ 的点对数量。 点分治
阅读全文
摘要:posted on 2021-09-12 15:49:52 | under 模板 | source 感觉不如直接复制 template <int N> struct dsu { int fa[N + 10], siz[N + 10], cnt; explicit dsu(int n = N) : c
阅读全文
摘要:posted on 2022-07-22 19:15:58 | under 模板 | source template<int N,class T=int,int logN=20> struct STable{ int tot,lg[N+10];T f[logN+1][N+10]; STable():
阅读全文
摘要:posted on 2022-10-18 13:30:17 | under 模板 | source const char* name="bit"; #include <cstdio> #include <cstring> #include <algorithm> using namespace st
阅读全文
摘要:posted on 2022-08-17 18:05:59 | under 模板 | source template<int N> struct lctree{ int val[N+10],sum[N+10],fa[N+10],ch[N+10][2],rev[N+10]; bool getson(i
阅读全文
摘要:posted on 2022-07-21 17:03:54 | under 模板 | source (介绍等会补) 调试: getpre、getsuf、find 手写,常数不要乘以二。 UB:getkth 和 getrnk 叠起来的时候 root 会改! UB:getpre、getsuf 的 val
阅读全文
摘要:posted on 2022-02-04 18:11:33 | under 模板 | source int popcount(int x){ #define BIT2(n) n,n+1,n+1,n+2 #define BIT4(n) BIT2(n),BIT2(n+1),BIT2(n+1),BIT2(
阅读全文
摘要:posted on 2022-08-10 18:07:25 | under 模板 | source 0x00 Bellman-Ford 最短路经过的边数不超过 $n-1$,因此若松弛轮数达到 $n$ 轮即有负环。复杂度 $O(nm)$。 int dis[100010]; bool vis[10001
阅读全文
摘要:posted on 2022-06-11 11:17:10 | under 模板 | source template<int N,int M=26,int D='a'> struct acam{ int ch[N+10][M],cnt[N+10],tot,fail[N+10]; int sum[N+
阅读全文
摘要:posted on 2022-01-17 16:13:39 | under 模板 | source #include <cstdio> #include <cstring> #include <algorithm> using namespace std; template<int N,int M=
阅读全文