HDU 4169 UVALive 5741 Wealthy Family】的更多相关文章

树形背包.DP递推的思路很简单.... 但是由于节点有15万个,先不论空间复杂度,这样开dp数组 dp[150000+10][300+10],如果初始化是memset(dp,-1,sizeof dp),则必然超时. 所以需要一个状态数剪枝...即记录这个节点最多组合的数量. UVALive是不限制内存的,所以dp[150000+10][300+10] 能够AC,HDU 4169 限制了内存大小,需要优化空间复杂度. 内存优化之后的代码,HDU上C++能AC,G++依旧MLE. #include<…
Problem Description While studying the history of royal families, you want to know how wealthy each family is. While you have various 'net worth' figures for each individual throughout history, this is complicated by double counting caused by inherit…
Wealthy Family Problem Description While studying the history of royal families, you want to know how wealthy each family is. While you have various 'net worth' figures for each individual throughout history, this is complicated by double counting ca…
题意:有水平N张牌,竖直M张牌,同一方向的牌不会相交.水平的和垂直的可能会相交,求最少踢出去几张牌使剩下的牌都不相交. 二分匹配 最小点覆盖=最大匹配. 链接:点我 坐标点作为匹配的端点 #include<cstdio> #include<iostream> #include<algorithm> #include<cstring> #include<cmath> #include<queue> #include<map>…
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=5741 [题目大意] 一个01相间的串,以0开头,给出的序列每个数字表示连续的0的个数或者1的个数,现在有m个询问,求0的个数为a且1的个数为b的串是否存在. [题解] 我们发现形如11001这样子以1为开头结尾的串是包含1001这样子的串的,同理以0为开头结尾的串也是包含了一些开头结尾数字相同的子串. 可以发现,当0的个数固定,1的个数是数轴上的一个区间,而且在0的个数相差1时,必定可以取到相同…
POJ 3342 Party at Hali-Bula / HDU 2412 Party at Hali-Bula / UVAlive 3794 Party at Hali-Bula / UVA 1220 Party at Hali-Bula(树型动态规划) Description Dear Contestant, I'm going to have a party at my villa at Hali-Bula to celebrate my retirement from BCM. I w…
POJ 1087 A Plug for UNIX / HDU 1526 A Plug for UNIX / ZOJ 1157 A Plug for UNIX / UVA 753 A Plug for UNIX / UVAlive 5418 A Plug for UNIX / SCU 1671 A Plug for UNIX (网络流) Description You are in charge of setting up the press room for the inaugural meet…
POJ 1511 Invitation Cards / UVA 721 Invitation Cards / SPOJ Invitation / UVAlive Invitation Cards / SCU 1132 Invitation Cards / ZOJ 2008 Invitation Cards / HDU 1535 (图论,最短路径) Description In the age of television, not many people attend theater perfor…
---恢复内容开始--- 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2962 Trucking Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 11428    Accepted Submission(s): 1104 Problem Description A certain lo…
离线处理+扫描线.题意很容易转化:若干个矩形形成并集,询问一些点是否在并集中? 官方题解不是这样做的....那种做法效率更高,暂时还不会.我这样是4500ms G++过的,C++TLE...... 区间加上某值,询问单点值,可以用树状数组.用线段树可能常数较大导致TLE. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #incl…