随笔分类 -  刘汝佳算法竞赛入门(紫书,蓝书)图论

摘要:最大独立集与最小顶点覆盖互补 阅读全文
posted @ 2018-01-30 18:18 lmjer 阅读(130) 评论(0) 推荐(0)
摘要:二分图最小覆盖数=最大匹配数 建模后即可 #include<cstdio>#include<cstring>#include<algorithm>using namespace std;struct my{ int next; int v;};const int maxn=1000000+10;co 阅读全文
posted @ 2018-01-30 11:27 lmjer 阅读(119) 评论(0) 推荐(0)
摘要:求出最小生成树后lca找最大权即可 #include<cstdio>#include<algorithm>#include<cstring>using namespace std;struct my{ int v; int next; int dist;};struct node{ int x,y; 阅读全文
posted @ 2018-01-28 11:37 lmjer 阅读(155) 评论(0) 推荐(0)
摘要:将一个节点扩展成为八个节点 #include<cstdio>#include<algorithm>#include<cstring>#include<queue>using namespace std;struct my{ int v; int next; int dist;};struct nod 阅读全文
posted @ 2018-01-25 20:53 lmjer 阅读(135) 评论(0) 推荐(0)
摘要:#include<cstdio>#include<cstring>#include<queue>#include<algorithm>using namespace std;struct my{ int v; int next; int dist;};const int maxn=10000;int 阅读全文
posted @ 2018-01-23 19:32 lmjer 阅读(182) 评论(0) 推荐(0)
摘要:#include<cstdio>#include<algorithm>#include<cstring>#include<queue>using namespace std;struct my{ int v; int next; double dist;};int m,n;const int max 阅读全文
posted @ 2018-01-21 12:07 lmjer 阅读(128) 评论(0) 推荐(0)
摘要:求出各点与终点的距离 ,然后在求得的DAG 上做动规 #include<cstdio>#include<cstring>#include<queue>#include<algorithm>using namespace std;struct my{ int v; int next; int dist 阅读全文
posted @ 2018-01-20 19:24 lmjer 阅读(109) 评论(0) 推荐(0)
摘要:2-sat 找好怎样连边即可 #include<cstdio>#include<algorithm>#include<cstring>using namespace std;const int maxn=1000000;bool mark[maxn*2+10];int age[maxn*2];int 阅读全文
posted @ 2018-01-18 19:26 lmjer 阅读(131) 评论(0) 推荐(0)
摘要:求图的缩点 阅读全文
posted @ 2018-01-07 11:58 lmjer 阅读(186) 评论(0) 推荐(0)
摘要:#include<cstdio> #include<cstring> #include<stack> #include<algorithm> using namespace std; struct my{ int v; int next; }; my bian[1000000+10]; stack< 阅读全文
posted @ 2018-01-07 11:57 lmjer 阅读(153) 评论(0) 推荐(0)
摘要:题意:给你n个珠子,一个珠子分为两半有两种颜色,用1到50来表示50种不同的颜色。把这些珠子串起来,两个紧挨着的珠子要满足一个条件就是接触的那部分颜色要相同 例如(1,2)(2,4),两个珠子的接触部分颜色相同都为2。当然,因为珠子最后是连成环的,第一个珠子和最后一个珠子也会接触,也要买满足这个条件 阅读全文
posted @ 2018-01-02 19:02 lmjer 阅读(206) 评论(0) 推荐(0)
摘要:2.解题思路:第一步是构造表达式树,构造时可以利用一个map来记录出现的子树,并为之编号。例如,用(a,0,0)可以表示一个叶子a,用(b,3,6)表示根的名字是b,子树的编号分别是3,6的树。这样既可方便地得到最简表达式。本题总的时间复杂度为O(N*logN)。 #include<stdio.h> 阅读全文
posted @ 2017-12-31 00:08 lmjer 阅读(349) 评论(0) 推荐(0)