
状态压缩
softrice
这个作者很懒,什么都没留下…
展开
-
hdu 4739——Zhuge Liang's Mines
用状态压缩较直观#include#include#includeusing namespace std;struct point{ int x,y;}a[100];bool cmp(point a,point b){ if(a.y<=b.y) { if(a.y==b.y) return a.x<b.x; else return 1; }原创 2013-09-17 22:17:05 · 668 阅读 · 0 评论 -
F - Deer-Proof Fence final
#include #include #include #include #include using namespace std; struct point { int x; int y; }points[1100]; double dp[1<<9];double d[1<<9];int n; int N;double a原创 2013-09-20 18:16:21 · 1058 阅读 · 0 评论 -
poj 3254 Corn Fields
状态压缩dp#include#include#includeusing namespace std;#define mod 100000000int n,m;int map[15];int dp[15][1<<12];int s[1<<12],cnt;bool judge(int x){ if((x<<1)&x) return 0; return 1; }v原创 2013-11-03 15:18:18 · 774 阅读 · 0 评论 -
hdu 1429 胜利大逃亡(续)
状态压缩+宽搜#include#include#include#includeusing namespace std;int n,m,t;int sx,sy;int vis[25][25][1<<12];char map[25][25];int dir[4][2]={1,0,-1,0,0,1,0,-1};struct state{ int x,y,k原创 2013-11-07 13:14:02 · 2491 阅读 · 0 评论 -
hdu 1400 Mondriaan's Dream
用1代表已经占有,0无被占有。先预处理出所有横放的状态。i-1行是0的地方肯定要放竖条。#include#include#includeusing namespace std;#define LL __int64int n,m;int s[1<<12],cnt;LL dp[12][1<<12];int judge(int x){ int num=0; for(原创 2013-11-07 21:55:19 · 931 阅读 · 0 评论 -
hdu 4778 Gems Fight!
状态压缩+dp因为bag数不超过21,所以我们用state表示: 0代表已经用过bag,1代表还没用过。dp【state】表示在当前状态下先手可获得最大差值。因为当你不管什么顺序选取bag,熔炉里的状态都是相同的,所以预处理出熔炉状态。状态转移方程:当有获得宝石x个,dp【state】=max(dp【state】,x+dp【state ' 】);当没有获得宝石,dp【state原创 2013-11-13 13:56:48 · 1009 阅读 · 0 评论 -
ZOJ 3675 Trim the Nails
状态压缩+暴搜#include#include#include#includeusing namespace std;#define LL long longstruct State{ int state,step; State(int sta=0,int ste=0) { state=sta; step=ste; }};LL cli1;LL cli原创 2013-11-13 15:14:56 · 4973 阅读 · 0 评论