摘要: http://poj.org/problem?id=3254第一个状压题 思路挺好想 用二进制表示每行的状态 然后递推用左移 右移来判断是不是01间隔出现 c大神教的 我的代码WA在这个地方了。。改了点 就A了 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define mod 100000000 8 #define LL long long 9 int a[15][15];10 LL dp[15][5050],s[15],num[2][5050],k[15],pp[15];1. 阅读全文
posted @ 2013-08-16 22:45 _雨 阅读(179) 评论(0) 推荐(0) 编辑
摘要: 题目链接推了半个下午。。写的三重超时了 加了点单调队列的思想 优化了下过了dp[i][j] 第二组的最右边的人选第J个人 那最左边肯定选第j-1个人 肯定是选相邻的dp[i][j] = min(o,dp[i-1][j-2]+(h[j]-h[j-1])*(h[j]-h[j-1])) 加个变量o保存 到j为止 最优的一个位置 j-2得满足条件 1 #include 2 #include 3 #include 4 #include 5 #define N 5010 6 #define M 3010 7 #define INF 0xfffffff 8 using namespace std; 9 i. 阅读全文
posted @ 2013-08-16 18:44 _雨 阅读(268) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=1191黑书上P116 想了挺久 没想出来 想推出一公式来着 退不出来。。想偏了 正解:递归 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 #define INF 0xfffffff 9 #define LL long long10 int dp[20][10][10][10][10];11 int aa[10][10],n;12 int divide(int k,int a,int b,int c,int. 阅读全文
posted @ 2013-08-16 18:33 _雨 阅读(228) 评论(0) 推荐(0) 编辑