HDU 3376
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3376题意:一个矩阵,每个点有价值,起点左上角终点右下角,每次只能走当前点的下一点或右一点,从起点走到终点,再从终点回到起点,走的点不能重复,问能取到的最大价值用费用流做建图:拆点(保证每个点只取1次),除了起点和...
阅读全文
HDU 1853
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1853和下题一模一样,求一个图环的并,此题的题干说的非常之裸露http://www.cnblogs.com/xiaohongmao/p/3873957.html#include #include #include ...
阅读全文
HDU 3455
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3435同下题,只是这题是双向边,同时让我认识到了一个问题,一个图拆点做二分图完美匹配的本质是求该图环的并http://www.cnblogs.com/xiaohongmao/p/3873957.html#inclu...
阅读全文
HDU 4861
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4861结论题:p是奇素数,1^n+2^n+...+(p-1)^n=0(mod p),其中p-1不整除n#include #include #include #include #include #include #i...
阅读全文
HDU 4862
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4862#include #include #include #include #include using namespace std ;const int INF=0xfffffff ;struct node{ ...
阅读全文
HDU 3488
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3488原来写过的一道题,今天重新看费用流又做了一遍题意:给一个图,求环的并(权值和最小)思路:每个点只能走一次,且都要走,所以一个点的出度入度均为1,因此拆点建图跑二分图最优匹配用费用流写的,速度比km慢#incl...
阅读全文
HDU 3998
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3998求LIS的长度,并且求有多少组互不相交的LIS求组数用最大流建图如下:if(dp[i]==1)add(S,i,1) ; if(dp[i]==ans)add(i+n,T,1) ;if(j>i && dp[j...
阅读全文
HDU 3364
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3364经典高斯消元解开关问题m个开关控制n个灯,开始灯全灭,问到达目标状态有几种方法(每个开关至多一次操作,不计顺序)一个灯的最终状态取决于x1^x2^...^xm,xi表示第i个开关的状态,1开0关所以根据题意建...
阅读全文
高斯消元
摘要:#include #include #include #include #include #include #include using namespace std ;const int MAXN=50;int a[MAXN][MAXN];//增广矩阵int x[MAXN];//解集bool fre...
阅读全文
HDU 4185
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4185两个挨着的'#'可以配成一对,求最多能配成几对挨着的'#'就连边,然后求一次最大匹配,答案是最大匹配除以二(因为1 2和2 1这两对匹配实际效果是1,但是会算成2)#include #include #inc...
阅读全文
HDU 4585
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4585从原来的人中找出战斗数值最接近的,输出他们两人的序号要在logn的复杂度完成查找,我用的是set,当然用map也可以,两个内部都是红黑树实现水题一道#include #include #include #in...
阅读全文
POJ 1182
摘要:http://poj.org/problem?id=1182带权并查集第一题,三种类型的生物,分别加入三个集合,题解见注释#include #include #include using namespace std ;#define MAX_N 150005int par[MAX_N] ;//父亲 ...
阅读全文
并查集
摘要:#define MAX_N 50005int par[MAX_N] ;//父亲 int rank[MAX_N] ;//树的高度 void INIT(int n){ for(int i=0 ;i<n ;i++){ par[i]=i ; rank[i]=0 ; }...
阅读全文
HDU 4268
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4268学会了multiset的用法,与set不同的是这个可以插入相同元素对w排序,对合适的w用multiset插入对应的h,logn完成查找#include #include #include #include #...
阅读全文