题目分析:
现在有n个村子,你想要用收买m个国家为你投票,其中收买第i个国家的代价是val[i]。但是有些国家存在从属关系,如果B从属于A国,则收买了A也意味着买通了B,而且这些关系是传递的。问你最小要付出的代价是多少?
这题的难点在于怎么建图,弱菜不会,只能膜拜大神的代码,然后自己捉摸着敲,dfs部分就和一般的树形DP+背包差不多,只是状态的初始化有些变化
建图需要加个...
分类:
其他好文 时间:
2014-07-29 14:38:38
阅读次数:
157
状压DP死活想不到啊,开始还以为是数据结构题,真是膜拜宋威大大。
包括点的矩形最小一定以这些点为顶点,所以枚举所有点对,构成所有状态。
由于不存在面积为0的矩形,所以当横纵坐标相同时得特判。
然后就是状压dp了。
#include
#include
#include
#include
#include
#include
#include
#include
using namespace s...
分类:
其他好文 时间:
2014-07-29 14:29:58
阅读次数:
217
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3329
回头重推式子
题解:http://blog.csdn.net/morgan_xww/article/details/6775853#reply
学到:
1、目前做的两道期望的状态转移方程都是从大向小推,定义方式:dp[i][j][k].... 满足i,j,k...
分类:
其他好文 时间:
2014-07-29 14:28:18
阅读次数:
264
题目:http://acm.hdu.edu.cn/showproblem.php?pid=4405
e[i]:当前在位置i还需要走的步数期望
受刘汝佳的AC自动机那个后缀链接写法的启发,我的x[i]通过逆序算出来连续有“flight line ”的时候,能到达的最远距离, rep(i,0,m)
{
scanf("%d%d",&xx,...
分类:
其他好文 时间:
2014-07-29 14:22:38
阅读次数:
252
Description
Given two positive integers n and k, you are asked to generate a new integer, say m, by changing some (maybe none) digits of n, such that the following properties holds:
m contains n...
分类:
其他好文 时间:
2014-07-29 14:22:18
阅读次数:
225
引言子序列和子字符串或者连续子集的不同之处在于,子序列不需要是原序列上连续的值。对于子序列的题目,大多数需要用到DP的思想,因此,状态转移是关键。这里摘录两个常见子序列问题及其解法。例题1, 最长公共子序列我们知道最长公共子串的求法,先温习一下,它的求法也是使用DP思想,对于 字符串s1 和字符串s...
分类:
其他好文 时间:
2014-07-29 13:58:08
阅读次数:
255
public String getSDPath(){File sdDir = null;boolean sdCardExist = Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED); ...
分类:
移动开发 时间:
2014-07-29 13:51:28
阅读次数:
228
1求 $\dps{\iint_D |x|\rd x\rd y}$, 其中 $D$ 为三角形 $\lap ABC:\ A(-2,0),B(1,1),C(2,3)$.2把 $\dps{\iiint_Vf(x,y,z)\rd x\rd y\rd z}$ 化为累次积分, 其中 $f(x,y,z)$ 为连续函...
分类:
其他好文 时间:
2014-07-29 13:48:38
阅读次数:
234
Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning ...
分类:
其他好文 时间:
2014-07-29 13:43:58
阅读次数:
223