
模板库~
蒟蒻小果冻
我太菜了
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
非常搞笑的LCT板子
const int Q=500000; int ls[Q],rs[Q],si[Q],v[Q],f[Q]; bool lazy[Q]; bool Isroot(int x) {return ls[f[x]]!=x&&rs[f[x]]!=x;} void update(int x) {si[x]=si[ls[x]]+si[rs[x]]+1;} void lx(int x) { ...原创 2018-05-11 21:46:39 · 280 阅读 · 0 评论 -
多项式全套(待续)
#include <stdio.h> #include <iostream> #include <algorithm> using namespace std; const int P=333333,MOD=998244353; inline int add(int a,int b) {a+=b;return a>=MOD?a-MOD:a;} inline原创 2018-12-31 16:31:46 · 251 阅读 · 0 评论 -
锕——放一个(不)通用的二分栈优化决策单调性DP板子
返回值为在最优条件下使用最少点数 int Gans(ll del,int n) { int hd=1,tl=0; st[0]=1; qu[++tl]=0; for(int i=1;i<=n;i++) { while(hd<tl&&st[qu[hd+1]]<=i)++hd; int now=qu[hd]; f[i]=G(i,now)+d原创 2018-12-25 08:42:01 · 394 阅读 · 0 评论 -
图的割点
好像快把割点怎么求忘了。。。复习一下 #include <cstdio> #include <iostream> #include <algorithm> using namespace std; const int Q=111111; int ans=0; int e[Q<<1],nn[Q<<1],las[Q],inc=0; int d...原创 2018-10-24 23:29:22 · 189 阅读 · 0 评论 -
Trajan
void dfs(int x) { inst[x]=1; st.push(x); dfn[x]=low[x]=++Time; for(int t=las[x];t;t=nn[t]) { int y=e[t]; if(!dfn[y])dfs(y),low[x]=min(low[x],low[y]); else if(inst[y])low[x]=min(low[x],dfn[y...原创 2018-10-25 22:12:09 · 282 阅读 · 0 评论 -
扩展Lucas板子
实在看不惯自己以前的代码风格,改了一下。。。 #include <cstdio> #include <iostream> using namespace std; inline int add(int a,int b,int p) {a+=b;return a>=p?a-p:a;} inline int ch(int a,int b,int p) {return...原创 2018-09-08 18:54:53 · 278 阅读 · 0 评论 -
需要修改的后缀自动机模板
#include <cstdio> #include <algorithm> #include <iostream> #include <cmath> #include <cstring> using namespace std; int tot=0,e[500000][26],maxn[500000],par[500000]; int ...原创 2018-05-21 19:26:36 · 144 阅读 · 0 评论 -
多项式开方板子
注意常数项要手动开方 void My_Sqrt(int a[],int Sqrt[],int toap) { if(toap==1){Sqrt[0]=Get_Sqrt(a[0]);return;} My_Sqrt(a,Sqrt,toap>>1); fill(Sqrt+(toap>>1),Sqrt+(toap<<1),0); co...原创 2018-05-07 09:26:17 · 292 阅读 · 0 评论 -
过不了编译的树剖板子
没有查过错。。。 很可能有问题。。。 const int Q=50000; int f[Q],id[Q],dep[Q],bs[Q],si[Q],toap[Q]; int last[Q],e[Q],nn[Q]; void Find_Best_Son(int x) { si[x]=1; int now=0; for(int t=last[x];t;t=nn[t]) ...原创 2018-05-11 22:17:35 · 160 阅读 · 0 评论 -
多项式除法板子
借鉴了OBlack大神的模版 见于NKOJ3215 #include <cstdio> #include <algorithm> #include <iostream> using namespace std; const int Q=500000,MOD=998244353; inline int add(int a,int b) {a+=b;return...原创 2018-05-05 17:27:36 · 387 阅读 · 0 评论 -
多项式求逆板子
建议搭配NTT板子食用~ 并且注意,函数结束后有可能需要清空[toap,2*toap)的值,不清空可能会爆 void GetInv(int a[],int ni[],int toap) { int i,now; ni[0]=ksm(a[0],MOD-2); for(now=2;now<=toap;now<<=1){ fill(...原创 2018-05-05 16:16:02 · 224 阅读 · 0 评论 -
应该正确的过不了编译的Hash表板子
膜数可改。。 const int MOD=72227 or 66666 or 997,Q=???; int las[MOD],v[Q],nn[Q],be[Q],inc; void _init() { memset(las,0,sizeof(las)); inc=0; } int _find(int k) { int x=k%MOD; for(int t=las...原创 2018-05-05 16:11:26 · 242 阅读 · 1 评论 -
乱搞的随机数
可能时间消耗稍微多一点。。 但应该比较随机。。。 #include &lt;cstdlib&gt; #include &lt;cstdio&gt; #include &lt;ctime&gt; using namespace std; bool a_rand() { int t=0; for(register int i=rand()%3;i&gt;=0;i--原创 2018-05-05 16:22:36 · 214 阅读 · 0 评论 -
NTT模版
emm 这好像是我第一次放模版。。 但是很懒,不想放头文件,反正函数部分对了就好吧。。。 const int Q=500000,MOD=998244353; inline int add(int a,int b) {a+=b;return a<MOD?a:a-MOD;} inline int sub(int a,int b) {a-=b;return a<0?a+MOD:a;}...原创 2018-05-05 15:53:48 · 232 阅读 · 0 评论 -
半平面交板子
O(n2):O(n^2):O(n2): #include &lt;cstdio&gt; #include &lt;iostream&gt; #include &lt;algorithm&gt; #include &lt;cstring&gt; #include &lt;cmath&gt; using namespace std; #define db原创 2019-01-08 00:24:41 · 288 阅读 · 0 评论