Marriage Ceremonies LightOJ - 1011 常规状压dp.popcount(S)表示S集合中元素数量.ans[S]表示S中的女性与前popcount(S)个男性结婚的最大收益. 那么,$ans[S]=max\{ans[S-p]+a[popcount(S)][p]\}$ 老代码 #include<cstdio> #include<cstring> #include<algorithm> using namespace std; ][],a[][]…
http://www.lightoj.com/volume_showproblem.php?problem=1011 You work in a company which organizes marriages. Marriages are not that easy to be made, so, the job is quite hard for you. The job gets more difficult when people come here and give their bi…
题目大意: 有N个男人,和N个女人要互相匹配,每个男人和每个女人有个匹配值. 并且匹配只能是1对1的. 问所有人都匹配完成,最大的匹配值是多少?   状压DP,暴力枚举就OK了, 这个题目略坑,因为他卡常数,可以有一些简单的优化,能优化1500ms............. =================================================================   #include<cstdio> #include<cstring> #i…
You work in a company which organizes marriages. Marriages are not that easy to be made, so, the job is quite hard for you. The job gets more difficult when people come here and give their bio-data with their preference about opposite gender. Some gi…
题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1158 题解:这题看起来就像是记忆搜索,由于s很少最多就10位所以可以考虑用状压.然后就简单了. #include <iostream> #include <cstring> #include <cstdio> using namespace std; ]; << ][] , d , dig[] , Po[] , L; int dfs(in…
题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1086 题解:题目就是求欧拉回路然后怎么判断有欧拉回路只要所有点的度数为偶数.那么就有欧拉回路所以只要找出度数为奇数的点然后在度数为奇数点之间选择两个这可以用状压来解决(由于无向图总的度数肯定是偶数的所以奇数度数的点肯定只有偶数个). #include <iostream> #include <cstring> #include <cstdio> #i…
题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1061 题解:显然能满足情况的8皇后的摆法不多,于是便可以用题目给出的状态来匹配各种满足情况的摆法然后找出最小值.还有关于题目的一个条件,皇后之间的移动不能越过皇后之间,其实这个条件并没什么用,因为如果某一个皇后挡住了另一个皇后的移动那么这种摆放方式肯定是不符合的那么肯定要移动某一个所以只要先移动挡住位置的皇后就行.所以得到了两个位置之间移动所需的花费,要么0要么1要么2.然后…
题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1119 题解:状压dp存一下车有没有被搞过的状态就行. #include <iostream> #include <cstring> #include <cstdio> using namespace std; typedef long long ll; ll dp[1 << 15] , val[15][15]; int main() {…
题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1037 #include <iostream> #include <cstring> #include <cstdio> #define inf 0X3f3f3f3f using namespace std; << ] , hp[]; ][]; int main() { ; scanf("%d" , &t); w…
1011 - Marriage Ceremonies   PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB You work in a company which organizes marriages. Marriages are not that easy to be made, so, the job is quite hard for you. The job gets more diff…