推荐网址,下面是别人的解题报告: http://www.cnblogs.com/chasetheexcellence/archive/2012/04/16/poj2441.html 里面有状态压缩论文的链接,可以看看. 该解题报告中用的是二维数组,但是很显然的是,递推式中的下一行只与上一行有关,类似于最长公共子序列,可以用滚动数组,在滚动数组后发现只用一个数组就可以了.至于是不是要和0-1背包一样得按从大到小的顺序,我没有,我的状态是从小到大的顺序,但是也AC了. 如果不用滚动数组,会超内存.…
题目链接: http://poj.org/problem?id=2441 Arrange the Bulls Time Limit: 4000MSMemory Limit: 65536K 问题描述 Farmer Johnson's Bulls love playing basketball very much. But none of them would like to play basketball with the other bulls because they believe that…
Description The CE digital company has built an Automatic Painting Machine (APM) to paint a flat board fully covered by adjacent non-overlapping rectangles of different sizes each with a predefined color. To color the board, the APM has access to a s…
Hie with the Pie Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 6436   Accepted: 3470 Description The Pizazz Pizzeria prides itself in delivering pizzas to its customers as fast as possible. Unfortunately, due to cutbacks, they can affo…
题意: 一共有m个城市,城市之间有双向路连接,一个人有n张马车票,一张马车票只能走一条路,走一条路的时间为这条路的长度除以使用的马车票上规定的马车数,问这个人从a出发到b最少使用时间. 分析: 状态压缩dp,用dp[i][j]表示到达j城市的最小时间,其中i为剩余车票的集合.集合i使用状态压缩的表示方法.由于剩余车票的集合不断变小,实际上为求DAG最短路问题. 代码: #include<cstdio> #include<cmath> #include<iostream>…
Description Farmer Johnson's Bulls love playing basketball very much. But none of them would like to play basketball with the other bulls because they believe that the others are all very weak. Farmer Johnson has N cows (we number the cows from 1 to…
Arrange the Bulls Time Limit: 4000MS   Memory Limit: 65536K Total Submissions: 5427   Accepted: 2069 Description Farmer Johnson's Bulls love playing basketball very much. But none of them would like to play basketball with the other bulls because the…
题意:给我们1*2的骨牌,问我们一个n*m的棋盘有多少种放满的方案. 思路: 状态压缩不懂看,http://blog.csdn.net/neng18/article/details/18425765 用1表示放置了骨牌,0表示没有放置.dp[i][j]表示第i行为状态j是有多少种方案. 分下面3种情况进行转移: d表示当前列号,s1 表示本行的状态,s2表示上一行的状态, 1 竖直放置   那么d=d+1,s1<<1|1 , s2<<1; 这是什么意思呢? 这表示上一行在d列没有放…
题意:略. 思路:由于每个大炮射程为2,所以如果对每一行状态压缩的话,能对它造成影响的就是上面的两行. 这里用dp[row][state1][state2]表示第row行状态为state2,第row-1行状态为state1时最多可以安放多少大炮. 则递推公式为:dp[i][K][J] = max(dp[i-1][L][K] + num[J]).其中num[J]表示状态J的二进制形式里有多少个1. 代码我是参考的别人的,觉得写得很好. 主要有一下几个地方: 1. 在判断一个数二进制形式有多少个1时…
Description Bugs Integrated, Inc. is a major manufacturer of advanced memory chips. They are launching production of a new six terabyte Q-RAM chip. Each chip consists of six unit squares arranged in a form of a 2*3 rectangle. The way Q-RAM chips are…