![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
状态压缩DP
team79
我在努力。
展开
-
hdu 2167 状态压缩DP
参看点击打开链接,或者黑书AC代码如下:#include #include #include #include using namespace std;const int K = 15;int dp[2][1<<K], prestatu;int num[55][55], N;int now, nowi;void DFS( int statu, int pos, int原创 2014-03-12 20:33:59 · 492 阅读 · 0 评论 -
hdu 4804 插头DP
和上一篇很像AC代码如下:#include #include #include #include using namespace std;const long long MOD = 1e9 + 7;int N, M, C, D;long long dp[2][21][1<<11];char str[110][15];int main(){ while( sca原创 2014-05-19 21:49:27 · 583 阅读 · 0 评论 -
poj 2411 状态压缩DP
解题报告:http://www.cppblog.com/sdfond/archive/2009/07/31/91761.htmlAC代码如下:#include #include #include #include #include using namespace std;vector hashs[1<<13];int M, N;long long dp[13][1<<13原创 2014-01-17 09:48:54 · 785 阅读 · 0 评论 -
lightoj 1086 状态压缩DP
题意:给定一个无相图,原创 2014-06-08 21:30:01 · 794 阅读 · 0 评论 -
lightoj 1119 状态压缩DP
dp[st]表示完成状态st中的任务所花的最少金钱,然后枚举其中原创 2014-06-09 16:27:58 · 1150 阅读 · 0 评论 -
lightoj 1061 状态压缩DP
题意:将所给棋盘上分布的棋子变成非攻击型的分布原创 2014-06-09 15:53:48 · 813 阅读 · 0 评论 -
lightoj 1158 状态压缩+数位DP
题意: dp[statu][premod]表示已经使用statu中的位置的数,且之前的余为premod的个数原创 2014-06-11 12:17:10 · 666 阅读 · 0 评论 -
uva 11825 状态压缩DP
妈蛋啊 一开始一直以为是树形dp的。。。。。然后这题其实可以原创 2014-05-31 21:53:45 · 688 阅读 · 0 评论 -
lightoj 1092 状态压缩DP
#include #include #include #include using namespace std;#define MAX 0x3f3f3f3fint R, C;int dp[10][1<<9][1<<9];int statu[10];char maps[10][10];int st_opt[1<<9][1<<9];int cnt_opt[1<<10];原创 2014-07-24 20:58:30 · 682 阅读 · 0 评论 -
hdu 4906 状态压缩DP
这题比赛的时候没能做出来,看的点击打开链接的思路原创 2014-08-01 22:49:52 · 707 阅读 · 0 评论 -
uva 11270 插头DP
思路见点击打开链接的第二种解法AC代码如下原创 2014-05-19 21:55:56 · 672 阅读 · 0 评论 -
vijos 1002 DP
首先,状态转移方程很好想,dp【i】 -原创 2014-04-09 12:10:23 · 1073 阅读 · 0 评论 -
poj 1185 状态压缩DP
这题开始直接状态压缩每行 2^M 然后就TLE了。。。。最后看了下别人的发现其实每行的状态没有这么多,因为相邻两个大炮的距离不能小于2 所以当M为10 的时候每行的状态只有60种,每次在得到M的时候,直接搜出这些状态保存起来,然后就可以了。。。。AC代码如下:#include #include #include #include using namespace std;in原创 2014-03-22 22:13:34 · 638 阅读 · 0 评论 -
hdu 3182 状态压缩DP
dp【statu】表示在该状态下消耗的能量 获得的价值从0到大递推即可AC代码如下:#include #include #include #include using namespace std;struct Node{ int id[101]; int tot;};struct DP{ int sumv; int sume;}dp原创 2014-03-10 19:25:01 · 754 阅读 · 0 评论 -
poj 1038 状态压缩dp
还在调试#include #include #include #include using namespace std;int pow[11] = { 1, 3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049 };int maps[160][11];int N, M, K;int dp[2][60000];int nowstat原创 2014-03-10 16:15:39 · 1035 阅读 · 0 评论 -
poj 1699 TSP
参考:点击打开链接AC代码如下:#include #include #include #include #include using namespace std;#define MAX 0x3f3f3f3fint increase[11][11];int N;int dp[11][1<<11];char s[11][30];int calc_lcs( strin原创 2014-02-17 14:39:50 · 770 阅读 · 0 评论 -
Poj 2404 状态压缩DP
本来是在light上看到的这题的。。。然后一直不过,没想到在poj上能过。。。。。。呵呵题目是说每条边至少走一次然后回到原点,那么找出所有奇数度的节点两两相连得到欧拉路AC代码如下:#include #include #include #include #include using namespace std;#define MAX 0x3f3f3f3fint min原创 2013-12-28 20:21:30 · 749 阅读 · 0 评论 -
hdu 4281 DP(多旅行商)
第一个问题:先枚举出所有可能的组合,然后剩下的就是01背包了。。。。第二个问题:多旅行商问题可以先求单个的旅行商,然后再合成多个的说实话第一次见到旅行商问题。。。。还是个多旅行商问题。。。。np[i]表示 经过i这个状态中的点后回到0点的最小时间cost[j][i]表示经过i中的状态的点后最后经过的是点j 然后求出单个的之后,从0开始dp上去,每次求得都是i状态下的原创 2013-11-20 22:15:57 · 1409 阅读 · 0 评论 -
hdu 1074 DP 二进制状态压缩
这里科目最大数目才15, 只要有全枚举的思想来DP就可以解决了, 有一个专有名词叫状态压缩DP. 状态压缩DP采用二制进的思想, 1, 0分别代表有或否. 如: 3的二进制为 11, 则代表完成了每一,二个科目的状态, 101代表完成了第一三两个科目的状态. 这样, 可以从0->(1 0则表示i在集合s上,反之..], 如果i在s集合内原创 2013-07-16 10:28:01 · 621 阅读 · 0 评论 -
hdu 1565 状态压缩DP
和点击打开链接这题很像,跑了2.8s,不知道那些0ms的怎么跑出来的,●rz#include #include #include #include using namespace std;int dp[2][1<<20], prestatu;int num[22][22], N;int now, nowi;void DFS( int statu, int pos, int原创 2014-03-12 19:49:48 · 547 阅读 · 0 评论 -
hdu 4539 状态压缩DP
参看点击打开链接,或者黑书这题就是在该题的基础上增加了一维。。。。悲剧的是,输入M,N弄反了,WA了半天AC代码如下:#include #include #include #include using namespace std;const int K = 10;int dp[2][1<<K][1<<K], prestatu1, prestatu2;int num[原创 2014-03-12 20:58:51 · 578 阅读 · 0 评论 -
poj 1691 状态压缩DP
WA了一次。。。。dp[statu][i] 表示状态statu中的块都已经涂了且最后一次涂得i所需要的最少拿起刷子次数然后转移就是枚举所有的块,判断能否刷,能刷就更新这题有一点要注意的是:只要是在该方块的上方有一部分接触就算邻接方块!!!妈蛋!我开始还以为要全部邻接才行AC代码如下:#include #include #include #include using原创 2014-04-02 16:03:44 · 532 阅读 · 0 评论 -
hdu 4529 状态压缩DP
按行来递推在递推的过程中每一行的状态与前原创 2014-08-24 11:53:38 · 624 阅读 · 0 评论