随笔分类 -  DP——区间

摘要:题目链接:http://lightoj.com/volume_showproblem.php?problem=1033#include #include #include #include #include #include #include using namespace std;const int maxe = 50000;const int maxn = 105;const int INF = 0x3f3f3f;int dp[maxn][maxn]; //dp[i][j]表示字符串中从i到j最少要添加的字母个数。int main(){ //freopen("E:\\acm\\. 阅读全文
posted @ 2013-09-05 19:28 等待最好的两个人 阅读(214) 评论(0) 推荐(0)
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4293#include#include#include#includeusing namespace std;const int maxn = 506;int G[maxn][maxn];int dp[maxn]; //dp[i]表示前i个人,最大有多少个人没撒谎。int main(){ //freopen("E:\\acm\\input.txt","r",stdin); int N; while(cin>>N){ memset(G,0,sizeo 阅读全文
posted @ 2013-09-05 00:03 等待最好的两个人 阅读(341) 评论(0) 推荐(0)
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4283#include#include#include#includeusing namespace std;const int maxn = 105;const int INF = 0x3f3f3f3f;int dp[maxn][maxn];//dp[i][j]表示只考虑编号为i到编号为j的人上场的最小不开心值;//枚举i第K(1=>T; for(int cas=1;cas>N; sum[0] = 0; for(int i=1;i=1;i--) ... 阅读全文
posted @ 2013-09-02 23:20 等待最好的两个人 阅读(199) 评论(0) 推荐(0)
摘要:题目链接:http://lightoj.com/volume_showproblem.php?problem=1031#include#include#include#includeusing namespace std;const int maxn = 105;int dp[maxn][maxn]; //dp[i][j] 表示先手从i到j比后手多的分差。int sum[maxn],a[maxn];int N;int main(){ // freopen("E:\\acm\\input.txt","r",stdin); int T; cin>> 阅读全文
posted @ 2013-08-28 20:03 等待最好的两个人 阅读(281) 评论(0) 推荐(0)
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4632用点容斥原理转移状态,dp[i][j]=dp[i+1][j]+dp[i][j-1]-dp[i+1][j-1]当 s[i] == s[j], 要加上dp[i+1][j-1] + 1;我就是想的太复杂,而这个题有卡时间,无限TLE,悲剧啊!#include #include #include #include #include #include #include #define maxn 1050#define INF 0x3f3f3fusing namespace std;const int.. 阅读全文
posted @ 2013-08-02 17:22 等待最好的两个人 阅读(214) 评论(1) 推荐(0)