摘要: #define repf(i,a,b) for(int i=(a);i>= 1; } return c; } 阅读全文
posted @ 2016-08-27 13:28 相儒以沫 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 差分约束基本思想:给出一些不等式,最后询问这些不等式是否能够同时成立 首先要将不等式换成dis(a)-dis(b)<=k的形式, 然后建立从b到a长度为k的边, 最后利用spfa求一遍最短路,判断是否有负环,即可 如果有负环,则说明该不等式组不能同时成立 spfa模版: 阅读全文
posted @ 2016-08-08 14:54 相儒以沫 阅读(143) 评论(0) 推荐(0) 编辑
摘要: twoset基本思想:有n个党派,每个党派有2个人,要求每个党派都要选出一个人,每个人之间可能存在互斥关系,判断最后能否选出这N个人来 阅读全文
posted @ 2016-08-08 14:46 相儒以沫 阅读(330) 评论(0) 推荐(0) 编辑
摘要: const int MAXN=5010; const int MAXM=2500000; struct Edge { int to,next; }edge[MAXM]; int head[MAXN],tot; int Low[MAXN],DFN[MAXN],Stack[MAXN],Belong[MAXN]; int Index,top; int scc; bool Instack[M... 阅读全文
posted @ 2016-08-08 14:33 相儒以沫 阅读(205) 评论(0) 推荐(0) 编辑
摘要: void dfs(int tmp[],int deep)//deep表示当前深度,temp_deep表示当前限定的最大深度,超过该深度,则不必继续下去 { if(flag) return; if(deep+8-check(tmp)>tmp_deep)//检查当前方案是否还有必要继续下去 return; if(check(tmp)==8)... 阅读全文
posted @ 2016-08-08 14:26 相儒以沫 阅读(210) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include #include using namespace std; const int INF=1e9; struct node { int to,w,next; }edge1[500010]; node edge2[500010]; struct A { int f,g,v; boo... 阅读全文
posted @ 2016-08-08 14:22 相儒以沫 阅读(185) 评论(0) 推荐(0) 编辑
摘要: struct point { double x,y; }; struct line { point a,b; }lines[110]; double chaji(point a,point b,point c,point d) { return (b.x-a.x)*(d.y-c.y)-(b.y-a.y)*(d.x-c.x); } bool isin(line l... 阅读全文
posted @ 2016-08-08 13:57 相儒以沫 阅读(1362) 评论(0) 推荐(0) 编辑
摘要: LL exp_mod(LL a, LL b, LL mod) { LL res = 1; while(b != 0) { if(b&1) res = (res * a) % mod; a = (a*a) % mod; b >>= 1; } return res; } LL Comb(LL a, LL b, LL... 阅读全文
posted @ 2016-08-05 09:18 相儒以沫 阅读(186) 评论(0) 推荐(0) 编辑
摘要: 函数: 使用方法: 阅读全文
posted @ 2016-08-03 18:55 相儒以沫 阅读(400) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include #include using namespace std; const int K=26;//一共有多少种字符 const int MAXC=500010;//模版串包含的字符数量 const int MAXN=1000010;//匹配串的最大长度 struct Trie { int next[M... 阅读全文
posted @ 2016-08-03 18:54 相儒以沫 阅读(179) 评论(0) 推荐(0) 编辑