算法模板
C20193620
A person can succeed at anything for which there is enthusiasm.
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
【模板】Tarjan(边双)
模板题 #include<cstdio> #include<algorithm> #include<cstring> #include<vector> #include<stack> using namespace std; struct mzls { int to,nt; }a[200005]; int n,m,ncnt,cnt;...原创 2019-10-24 21:04:19 · 282 阅读 · 0 评论 -
【模板】树链剖分
模板题 #include<cstdio> #include<cstring> #include<algorithm> using namespace std; #define lch i<<1 #define rch i<<1|1 #define N 30005 struct mzls { int to,nt; }a[N*2]; s...原创 2019-10-03 11:43:50 · 278 阅读 · 0 评论 -
【模板】树上莫队
模板题 #include<bits/stdc++.h> using namespace std; #define N 100005 vector<int>g[N]; int st[N],nd[N],a[N]; int pos[N],dfn[N],cnt,sum[N]; int fa[N][20],dep[N],ans[N],n,m,an; bool f[N]; stru...原创 2019-10-03 11:39:12 · 303 阅读 · 0 评论 -
【模板】带修莫队
模板题 #include<bits/stdc++.h> using namespace std; int n,a[300005],pos[300005],m,sum[1000005],ans[2000005],t1,t2,a2[2000005][2],la[2000005],a3[1000005]; struct mzls { int l,r,id,mo; bool opera...原创 2019-10-03 11:09:35 · 254 阅读 · 0 评论 -
【模板】莫队
模板题 #include<bits/stdc++.h> using namespace std; int n,a[300005],pos[300005],m,sum[1000005]; long long ans[2000005],x; struct mzls { int l,r,id; bool operator<(const mzls &x)const { ...原创 2019-10-03 11:05:53 · 250 阅读 · 0 评论 -
【模板】Dancing-Link X
模板题 #include<cstdio> #include<algorithm> #include<cstring> #include<cmath> using namespace std; #define N 1005 #define INF 0x3f3f3f3f int n,m; int row[N*N],s1[N]; int L[N*N],...原创 2019-10-03 10:51:16 · 261 阅读 · 0 评论 -
【模板】BSGS
模板题 #include<cstdio> #include<algorithm> #include<cmath> #include<cstring> using namespace std; typedef long long LL; #define hmod 1389001 LL A,B,mod; inline LL Pow(LL a,LL b...原创 2019-10-03 10:48:02 · 257 阅读 · 0 评论 -
【模板】Miller-Rabin素性测试与Pollard-Rho因数分解
#include<cstdio> #include<algorithm> using namespace std; typedef long long LL; const int prim[]={2,3,5,7,11,13,17,19,23,29}; inline LL Add(LL a,LL b,LL mod) { LL ret=0; while(b) { i...原创 2019-09-17 22:07:42 · 304 阅读 · 0 评论 -
【模板】树上启发式合并
模板题 #include<bits/stdc++.h> using namespace std; #define N 100005 int n,a[N],ans[N],son[N],siz[N]; vector<int>g[N]; int f[N],sum,m; inline void dfs1(int x,int fa) { siz[x]=1; int ml=0,...原创 2019-08-04 11:11:49 · 423 阅读 · 0 评论 -
【模板】最短路Dijkstra
模板题 #include<bits/stdc++.h> using namespace std; #define N 200005 struct mzls { int nt,w,to; }a[N]; struct node { int x1,dis; node(){} node(int x,int y) { x1=x,dis=y; } }; bool operato...原创 2019-07-19 08:57:36 · 214 阅读 · 0 评论 -
【模板】扩展中国剩余定理
模板题 推荐博客 #include<cstdio> #include<algorithm> using namespace std; typedef long long LL; #define N 1005 inline LL exgcd(LL a,LL b,LL &x,LL &y) { LL d=a; if(b>0) { d=exgc...原创 2019-03-18 13:36:02 · 287 阅读 · 0 评论 -
【模板】后缀数组
模板 #include<bits/stdc++.h> #define N 1000005 using namespace std; int t1[N],t2[N],sa[N],h[N],rk[N],c[N],a[N],g[36][N],lg[N]; inline void SA(int n,int m) { //DA->SA int *x=t1,*y=t2,p=0,...原创 2019-02-20 22:38:45 · 253 阅读 · 0 评论 -
【模板】网络流Dicnic
模板题 #include<cstdio> #include<algorithm> #include<cstring> #include<queue> using namespace std; #define N 1000005 typedef long long LL; #define INF 1000000000000000000ll s...原创 2019-01-29 14:39:48 · 423 阅读 · 0 评论 -
【模板】AC自动机
模板题 #include<cstdio> #include<cstring> #include<queue> #include<algorithm> using namespace std; struct mzls { int next[26],fail,count; void init() { memset(next,-1,si...原创 2019-01-29 14:36:18 · 260 阅读 · 0 评论 -
【模板】Splay
模板题 #include<cstdio> #include<algorithm> using namespace std; #define N 100000 #define INF 2000000005 struct mzls { mzls *ch[2]; mzls *fa; int key; int siz; }t[N+5]; mzls *root,*N...原创 2019-01-29 14:34:16 · 273 阅读 · 0 评论 -
【模板】欧拉回路
题目 注意欧拉回路和欧拉路径的区别 #include<bits/stdc++.h> using namespace std; int T,n,m,aa; bool f1[200005],vis[200005],f2[200005]; int a1[200005][2],c[200005],id[200005],ans[200005],s,t,d,t2; inline int ab...原创 2018-11-28 13:45:06 · 438 阅读 · 0 评论 -
【模板】Tarjan(割点&割边)
题目 #include<cstdio> #include<algorithm> #include<cstring> #include<vector> using namespace std; struct mzls { int to,nt; }a[200005]; int n,m,ncnt,cnt; int low[20005],dfn[200...原创 2018-11-28 13:20:50 · 423 阅读 · 0 评论 -
【模板】声明
本版块主要为博主个人所用,仅供参考原创 2018-11-26 23:19:48 · 532 阅读 · 0 评论 -
【模板】Manacher算法
模板题 推荐博客 #include<iostream> #include<string> using namespace std; int p[30000005]; inline int M(string s) { string s1="$#"; for(int i=0;i<s.size();i++) { s1+=s[...原创 2018-11-26 23:19:56 · 113 阅读 · 0 评论
分享