随笔分类 -  算法--动态规划--状压dp

摘要:[传送门[(http://www.51nod.com/Challenge/Problem.html ! problemId=1518) 解题思路 直接算不好算,考虑容斥,但并不能把行和列一起加进去容斥,这会使时间复杂度非常高,那么就考虑枚举行后$dp$。设$f[i]$表示存在$i$列有线,任意一行无 阅读全文
posted @ 2019-02-18 09:36 Monster_Qi 阅读(369) 评论(0) 推荐(0)
摘要:"传送门" 解题思路 第一种方法是状压$dp$,设$f(S)$为状态$S$到取完的期望步数,那么$f(S)$可以被自己转移到,还可以被$f(S|(1 include include include include using namespace std; const int N=20; int n; 阅读全文
posted @ 2019-01-14 18:44 Monster_Qi 阅读(159) 评论(0) 推荐(0)
摘要:[传送门[(https://www.luogu.org/problemnew/show/CF16E) 解题思路 比较简单的状压+期望。设$f[S]$表示$S$这个状态的期望,转移时挑两条活着的鱼打架。时间复杂度$O(2^n n^2)$。 代码 cpp include include include 阅读全文
posted @ 2018-12-01 20:29 Monster_Qi 阅读(213) 评论(0) 推荐(0)
摘要:传送门 解题思路 首先我们发现这道题s的长度很小,所以考虑点暴力的做法,状压dp或搜索。本蒟蒻搜索永远调不对,所以就写了个状压dp。因为所有s里的数都要出现一次,并且最后的答案是要求整除,那么我们设dp[S][k]表示现在所选的状态集合为S,当前所选的数组成的数字对d取余后的值为k,这样就可以转移了 阅读全文
posted @ 2018-09-29 17:47 Monster_Qi 阅读(134) 评论(0) 推荐(0)
摘要:传送门解题思路状压dp,记录路径条数,dp[S][i][j]表示状态为S,前一个点是i,再前一个点是j的最大值,然后在开个一样的数组记录方案数,时间复杂度O(2^n*n^2),注意要用long long,还有数据有一个点的情况。代码#include#incl... 阅读全文
posted @ 2018-09-16 14:50 Monster_Qi 阅读(157) 评论(0) 推荐(0)
摘要:题目描述Farmer John is at the market to purchase supplies for his farm. He has in his pocket K coins (1 #include#include#includeusing... 阅读全文
posted @ 2018-08-12 07:55 Monster_Qi 阅读(147) 评论(0) 推荐(0)
摘要:题目描述Farmer John and his herd are playing frisbee. Bessie throws thefrisbee down the field, but it’s going straight to Mark the fi... 阅读全文
posted @ 2018-07-29 19:06 Monster_Qi 阅读(144) 评论(0) 推荐(0)
摘要:传送门 解题思路去年noip现在拿来写。。思路还是听清楚的,记忆化搜索,f[S]表示现在选了集合S时的最小代价,dis[i]表示达到最优时i这个点的深度。f[S| (1#include#include#includeusing namespace std;c... 阅读全文
posted @ 2018-07-25 14:52 Monster_Qi 阅读(132) 评论(0) 推荐(0)
摘要:题目描述A little known fact about Bessie and friends is that they love stair climbing races. A better known fact is that cows really ... 阅读全文
posted @ 2018-07-17 19:53 Monster_Qi 阅读(181) 评论(0) 推荐(0)
摘要:Time Limit: 10 Sec Memory Limit: 162 MB Submit: 1300 Solved: 763 [Submit][Status][Discuss] Description混乱的奶牛 [Don Piele, 2007] F... 阅读全文
posted @ 2018-07-17 19:00 Monster_Qi 阅读(135) 评论(0) 推荐(0)
摘要:题面题解好像昨天wxl大爷讲的是O(Tn*2^n)的做法,后来没想通,就自己写了个O(Tn^2*2^n)的暴力状压,莫名其妙过了??数量级二十亿??懵逼,可能到了CCF老爷机上就T了。dp[S]表示现在猪的状态,然后枚举两只鸟,然后开炮。代码#include... 阅读全文
posted @ 2018-06-19 11:51 Monster_Qi 阅读(103) 评论(0) 推荐(0)
摘要:1087: [SCOI2005]互不侵犯KingTime Limit: 10 Sec Memory Limit: 162 MB Submit: 5333 Solved: 3101 [Submit][Status][Discuss] Description... 阅读全文
posted @ 2018-06-05 19:25 Monster_Qi 阅读(125) 评论(0) 推荐(0)
摘要:题目描述司令部的将军们打算在N*M的网格地图上部署他们的炮兵部队。一个N*M的地图由N行M列组成,地图的每一格可能是山地(用“H” 表示),也可能是平原(用“P”表示),如下图。在每一格平原地形上最多可以布置一支炮兵部队(山地上不能够部署炮兵部队);一支炮兵... 阅读全文
posted @ 2018-06-04 11:23 Monster_Qi 阅读(145) 评论(0) 推荐(0)
摘要:DescriptionSquares and rectangles fascinated the famous Dutch painter Piet Mondriaan. One night, after producing the drawings in ... 阅读全文
posted @ 2018-03-07 23:10 Monster_Qi 阅读(109) 评论(0) 推荐(0)