上一页 1 ··· 19 20 21 22 23 24 25 26 27 ··· 47 下一页

2012年8月2日

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=3333离线算法,和上一题一模一样。。。View Code #include <iostream>#include <algorithm>#include <map>using namespace std ;const int maxn=30001 ;typedef __int64 LL ;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1map <int,int> hash ;struct n 阅读全文
posted @ 2012-08-02 20:37 LegendaryAC 阅读(108) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=3874今天和涂涂新学的离线算法,太牛了大概就是先接收所有数据,然后按查询右边界排序,从左往右更新,遇到之前加过的数就删掉,因为按右边界排序,所以查询区间不断右移,删掉不会出错View Code #include #... 阅读全文
posted @ 2012-08-02 20:35 LegendaryAC 阅读(273) 评论(0) 推荐(0) 编辑

2012年7月30日

摘要: http://acm.bjtu.edu.cn/vjudge/problem/viewProblem.action?id=1815经典的双线程dp,dp[i][x1][y1][x2][y2]表示走i步在(x1,y1),(x2,y2)两点处取得的和的最大值,假设矩阵从0-n-1,有i=x+y,五维转化成三维。代码中用了滚动数组,不过在这里意义不大View Code #include <iostream>using namespace std ;int map[31][31],dp[3][31][31] ;int MAX(int a,int b,int c,int d){ a=max(a 阅读全文
posted @ 2012-07-30 23:07 LegendaryAC 阅读(245) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.bjtu.edu.cn/vjudge/problem/viewProblem.action?id=669最最基础的树形dp,父子兄弟结构太爽了,学自hh博客View Code #include <iostream>using namespace std ;struct Tree{ int father ; int child ; int brother ; int happy ; int temp ; int MAX(){ return max(happy,temp) ; } void init(){ ... 阅读全文
posted @ 2012-07-30 23:01 LegendaryAC 阅读(251) 评论(2) 推荐(0) 编辑

2012年7月29日

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1114完全背包,求最小值View Code #include <iostream>using namespace std ;int V ;int dp[1000001] ;const int INF=0xfffffff ;void CompletePack(int c,int w){ for(int i=c;i<=V;i++) dp[i]=min(dp[i],dp[i-c]+w) ; return ;}int c[50001],w[50001] ;int main(){ in... 阅读全文
posted @ 2012-07-29 16:29 LegendaryAC 阅读(143) 评论(0) 推荐(0) 编辑

2012年7月27日

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2844求的是能买多少种价钱的物品,多重背包教主很经典的男人八题之一。。。不过据说原题要用单调队列优化,这个二进制优化就过了。。。View Code #include <iostream>using namespace std ;int V ;int dp[100001] ;void ZeroOnePack(int c,int w){ for(int i=V;i>=c;i--) dp[i]=max(dp[i],dp[i-c]+w) ; return ;}void CompletePac... 阅读全文
posted @ 2012-07-27 16:08 LegendaryAC 阅读(260) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1059基础的二进制优化的多重背包View Code #include <iostream>using namespace std ;int V ;int dp[200001] ;void ZeroOnePack(int c,int w){ for(int i=V;i>=c;i--) dp[i]=max(dp[i],dp[i-c]+w) ; return ;}void CompletePack(int c,int w){ for(int i=c;i<=V;i++) ... 阅读全文
posted @ 2012-07-27 15:10 LegendaryAC 阅读(143) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1702G++交,基本stl栈和队列操作View Code #include <iostream>#include <stack>#include <queue>using namespace std ;int main(){ int t ; scanf("%d",&t) ; while(t--) { int n,m ; string str ; cin >> n >> str ; if(str=="FIFO&qu 阅读全文
posted @ 2012-07-27 14:05 LegendaryAC 阅读(254) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4314dp,dp[i][j]表示i个小矮人能逃出去j个时需要之前井中剩下的人的最小a高度之和转移方程dp[i][j]=min(dp[i-1][j]-kk[i-1].a,max(dp[i-1][j-1],h-sumA[i-1]-kk[i-1].b))最神的是解题报告直接把a+b排了个序(a+b最小的先逃脱),这个自己没看出来。。。View Code #include <iostream>#include <algorithm>using namespace std ;const int 阅读全文
posted @ 2012-07-27 11:59 LegendaryAC 阅读(320) 评论(0) 推荐(0) 编辑

2012年7月26日

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4310解题报告正解是状压dp,当时做反正就贪心贪过去了。。。运气真好。。。View Code #include <iostream>#include <algorithm>using namespace std ;typedef struct L{ int dps,hp ; double ab ;}L ;L kk[1001] ;bool cmp(L a,L b){ return a.ab>b.ab ;}int main(){ int n ; while(~scanf(" 阅读全文
posted @ 2012-07-26 18:14 LegendaryAC 阅读(168) 评论(0) 推荐(0) 编辑
上一页 1 ··· 19 20 21 22 23 24 25 26 27 ··· 47 下一页