摘要: (初学绕路,名词都默认)特别牛逼的konig: 二分图中,最大匹配==最小点集覆盖 基本记住这个就行了。 证明是构造性的,写出一个正确的算法,然后证明它执行完就得到了最小点集覆盖,并且等于匹配数。 算法:匈牙利从右边,从未配节点继续找增广路,肯定找不到,但找到了一个个V,W,VW,WW形的不完整增广路。将不完整增广路上的点都染黑色。取左边黑点,右边白点。 证明1: 要证这样取得的点数恰为匹配数。 证明点与匹配是一一对应的。 显然左边黑点都对应一条匹配边,且匹配边右侧也为黑色。 右边白点向左连的边一定有一条匹配边且不能构成V字路, 左侧为白色。 (即把匹配边分成两类,属于V字... 阅读全文
posted @ 2013-02-13 10:37 Moretimes 阅读(185) 评论(0) 推荐(0) 编辑
摘要: 百度文库搜trie图利用安全图的概念可以做POJ2778POJ2778 1 #include <cstdio> 2 #include <cstring> 3 const int p = 1e5; 4 int trie[170][4], map[255], fail[150], q[2000000], cnt; 5 bool v[170]; 6 struct M { 7 long long s[170][170]; 8 M () { memset (s, 0, sizeof s); } 9 }x, ans;10 inline M operator * (const M & 阅读全文
posted @ 2013-02-08 16:58 Moretimes 阅读(185) 评论(0) 推荐(0) 编辑
摘要: x * x + y * y = r * r的(正整数解 + 1) 2 #include 3 long long r; 4 inline long long gcd (long long a, long long b) { return b == 0 ? a : gcd (b, a % b); }... 阅读全文
posted @ 2013-02-08 16:54 Moretimes 阅读(1128) 评论(0) 推荐(0) 编辑
摘要: A1 + X1 - X2 = GA2 + X2 - X3 = G...An + Xn - X1 = G解得X1 = X1X2 = A1 - G + X1X3 = A1 + A2 - G - G + X1...Xn = sigma(1, n)A - n * G + X1注意到ans = abs (X1 - lamda1) + abs (X2 - lamda2) + ... + abs (Xn - lamdan)于是sort 取中位数代码丑极了替换的 1 #include <cstdio> 2 #include <cstdlib> 3 #include <algori 阅读全文
posted @ 2013-02-08 16:47 Moretimes 阅读(517) 评论(0) 推荐(0) 编辑
摘要: 经典代码 来自YXCYMYXC 1 #include <cstdio> 2 #include <iostream> 3 using namespace std; 4 double t; 5 int x, y, n; 6 inline double DFS (double a, double b, int n) 7 { 8 double s = 2e18; 9 if (n == 1)10 return max (a, b) / min (a, b);11 for (int i = 1, j = n - 1; i <= j; i ++, j --)12 ... 阅读全文
posted @ 2013-02-04 11:06 Moretimes 阅读(208) 评论(0) 推荐(0) 编辑
摘要: 黑书上猴子内个题 逆向思维真是吊View Code 1 #include <cstdio> 2 #include <cstring> 3 const int N = 500000, M = 500000; 4 int key[M], head[N], next[M], cnt; 5 int a[N], p[N], ans[N]; 6 bool v[N]; 7 inline void add (const int & x, const int & y) 8 { 9 key[cnt] = y;10 next[cnt] = head[x];11 head[x] 阅读全文
posted @ 2013-02-04 11:00 Moretimes 阅读(739) 评论(0) 推荐(0) 编辑
摘要: 想到冗余就差不多了 单调队列View Code 1 #include <cstdio> 2 const int N = 501000; 3 int q[N], loc[N], h, t, n, d, len; 4 inline void INSERT (int x) 5 { 6 while (h <= t && q[t] < x) t --; 7 q[++ t] = x;loc[t] = ++ len; 8 } 9 inline int QUERY (int x)10 {11 int st = 0, ed = t + 1, mid;12 while (s 阅读全文
posted @ 2013-02-04 10:58 Moretimes 阅读(278) 评论(0) 推荐(0) 编辑
摘要: 基于kruscal的贪心 可以有如下推论:两个不同的最小生成树所用的的相同边权的边的数量相同。可以做这样的理解:当进行到选第K大的边时,联通快数是一定的所以的、一定需要K- 1个该权值边 (不知道对不对 欢迎TuneProverbs指正)SB没想好怎么存水体写半天。。。。。。。我是SB 1 #include <cstdio> 2 #include <vector> 3 #include <cstring> 4 #include <iostream> 5 #include <algorithm> 6 using namespace st 阅读全文
posted @ 2013-02-04 10:55 Moretimes 阅读(328) 评论(0) 推荐(0) 编辑
摘要: 师爷:你叫张麻子?可你脸上没麻子啊!张麻子:黄四郎脸上有四吗?View Code 1 #include <iostream> 2 #include <cstdio> 3 #include <algorithm> 4 #include <cstring> 5 using namespace std; 6 const int N = 30000; 7 int key[N], next[N], len[N], head[N], cnt, d[N], s[N], q[N], t, a[N], a_c, f[N], dist, ans, n; 8 bool 阅读全文
posted @ 2013-01-16 23:19 Moretimes 阅读(349) 评论(0) 推荐(0) 编辑
摘要: 黄四郎:三天之后,一定让县长过了作诗!张麻子:汤师爷,他是原来过不了作诗的你现在也过不了作诗,你给翻译翻译,什么叫常数?张麻子:翻译翻译,什么叫常数!汤师爷:这还用翻译?都说了张麻子:我让你翻译给我听,什么叫常数!汤师爷:不用翻译,就是常数啊难道你听不懂什么叫常数?张麻子:我就想让你翻译翻译,什么叫常数!汤师爷:常数嘛!张麻子:翻译出来给我听!什么他妈的叫常数!什么他妈的叫他妈的常数!汤师爷:什么他妈的叫常数啊?黄四郎:常数就是三天之后,你依然过不了作诗!明白了吗?汤师爷:这就是常数啊!什么他妈的叫他妈的常数 1 #include <cstdio> 2 #include <c 阅读全文
posted @ 2013-01-16 23:15 Moretimes 阅读(488) 评论(0) 推荐(1) 编辑