
模板
文章平均质量分 78
gotoac
这个作者很懒,什么都没留下…
展开
-
[gotoac]划分树 beta1
struct DivideTree{ #define lson l,mid,floor+1 #define rson mid+1,r,floor+1 int tol[22][M]; //tol[i][j]:第i层第j个前有多少个数分配到左子 int val[22][M],sorted[M]; //val[0]是原始数组,sorted是升序排序后的数组 v原创 2012-11-08 20:19:06 · 510 阅读 · 0 评论 -
[gotoac]高斯消元
int gcd(int a,int b){ if(a>b) swap(a,b); while(b){int t=b;b=a%b,a=t;} return a; } int lcm(int a,int b){ return a/gcd(a,b)*b; } int gauss(int equ,int var,int a[][M]){ int i,j,原创 2013-05-09 16:18:45 · 701 阅读 · 0 评论 -
[gotoac]强连通+缩点
struct Node{ int v,next; }edge[M<<1];//原图的边 int now[M],init[M];//新图的邻接表表头,原图的邻接表表头 int pre[M],Index;//访问顺序 int low[M],idx[M],hash[M];//追溯的最早次序,点在新图的id,哈希新图的边 int ss[M],top;//放节点的栈 int n , nn , len转载 2013-05-09 16:16:50 · 747 阅读 · 0 评论 -
无聊存存~
#pragma comment(linker, "/STACK:102400000,102400000") #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define原创 2013-05-03 12:22:49 · 594 阅读 · 0 评论 -
后缀数组+RMQ
源处:http://www.notonlysuccess.com/index.php/sa/ //rank从0开始 //sa从1开始,因为最后一个字符(最小的)排在第0位 //high从2开始,因为表示的是sa[i-1]和sa[i]的LCP #define M 220000 int rk[M],sa[M],X[M],Y[M],high[M],init[M]; int buc转载 2013-04-25 15:14:04 · 771 阅读 · 0 评论 -
[gotoac] sap(bfs+邻接表) beta1
struct sap{ typedef int type; struct edge{ int to,next; type flow; }edg[999999];//边表 int n,m;//顶点数,边数 int g[M],cur[M],pre[M];//邻接表,当前弧,上一个点 int dis[M],gap[M];//层次数组,间隙优化 int q[M],head,tail;原创 2012-12-13 23:06:27 · 622 阅读 · 0 评论 -
[gotoac]网络流SAP(邻接表&邻接矩阵) beta2
#define getmin(x,y) (x= (xstruct sap{//动态邻接表 typedef int type; //流量的类型 struct edge{ int from,to; type flow; //该条边的剩余流量 edge(int u=0,int v=0,type f=0){from=u,to=v,flow=f;} }; int n,m;原创 2012-11-08 20:34:20 · 664 阅读 · 0 评论 -
[gotoac]二分图最大匹配hungary & 二分图最佳完美匹配KM(邻接表&邻接矩阵) beta1
struct hungary{ int n,m; //X集和Y集的点数 int match[M]; //匹配 bool vis[M]; //是否在增广路上 vectorg[M]; //邻接表 void init(int _n,int _m){ n=_n,m=_m,clr(match,-1,m); for(int i=0;i<n原创 2012-11-30 16:22:05 · 614 阅读 · 0 评论 -
[gotoac]费用流spfa beta1
struct costFlow{//邻接表 typedef int type; struct edge{ int from,to; type flow,cost; edge(int u=0,int v=0,type f=0,type c=0){ from=u,to=v,flow=f,cost=c; } }; vectoredg; //边表 vectorg[M];原创 2012-11-30 14:13:01 · 453 阅读 · 0 评论 -
[gotoac]有关字符串
最小表示法: int getMin(int *str,int len){ int p1=0,p2=1,k=0; while(p1<len && p2<len && k<len){ int dif=str[p1+k]-str[p2+k]; if(dif){ if(dif>0) p1= (p1+k+1<=p2)? p2:p1原创 2013-05-09 12:09:17 · 624 阅读 · 0 评论