E-COM-NET
首页
在线工具
Layui镜像站
SUI文档
联系我们
推荐频道
Java
PHP
C++
C
C#
Python
Ruby
go语言
Scala
Servlet
Vue
MySQL
NoSQL
Redis
CSS
Oracle
SQL Server
DB2
HBase
Http
HTML5
Spring
Ajax
Jquery
JavaScript
Json
XML
NodeJs
mybatis
Hibernate
算法
设计模式
shell
数据结构
大数据
JS
消息中间件
正则表达式
Tomcat
SQL
Nginx
Shiro
Maven
Linux
ACM--状态压缩DP
HDOJ 1400 & POJ 2411 - Mondriaan's Dream
状态压缩DP
dp[r][k]代表第r行的占有情况是二进制k(0为空,1为已占)....每次更新枚举每行的情况..看怎么来摆..首先要保证摆的自我不冲突.然后它的更新来源可以推出来(因为每个方块最多影响其上一层的..而题目要求必须所有位置都填满..那么确定了本行的放置情况,其中竖着放回占有上面一行的一格,所以上行对应的就是0....不放或横着放必须保证上面已经占有.即上一行对应位置为1..)...Progr
kk303
·
2013-07-16 17:00
HDOJ 2442 -bricks 六进制
状态压缩DP
一直TLE.打表过的..
有5个砖块..加上一个空着不放..那么有6种状态..所以很明显的可以用6进制的状态DP... 不过这么做..我觉得我已经能优化的都优化了...还是超时..一看数据范围是100*6..打表先AC了.. 看有大神用3进制状态DP水过..Orz...看了好久没看懂...觉得自己状态DP还是很表面~~Program:#include #include #include #include #incl
kk303
·
2013-07-16 16:00
HDOJ 2640 - Toy bricks
状态压缩DP
这道题和炮兵阵地很像,不同的是炮兵阵地是每个炮兵不能相互干扰..这题是每个块不能有交集...处理起来稍微麻烦点...Program:#include #include #include #include #include #include #defineoo1000000007 #definelllonglong #definepiacos(-1.0) #defineMAXN505 usin
kk303
·
2013-07-16 12:00
sgu 223 - Little Kings
状态压缩DP
裸状态DP....dp[n][k]...n表示当前的状态...k表示已经放好的King数量 Program:#include #include #include #include #include #include #defineoo1000000007 #definelllonglong #definepiacos(-1.0) #defineMAXN505 usingnamespacestd
kk303
·
2013-07-16 10:00
sgu 222 - Little Rooks 简单的
状态压缩DP
每行的状态用二进制数表示~~自己好些地方没细心~导致WA了很久..Program:#include #include #include #include #include #include #defineoo1000000007 #definelllonglong #definepiacos(-1.0) #defineMAXN505 usingnamespacestd; lldp[12][1
kk303
·
2013-07-14 20:00
HDU 4540 威威猫系列故事——打地鼠 (
状态压缩DP
)
威威猫系列故事——打地鼠 Time Limit: 300/100 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 755 Accepted Submission(s): 416 Problem
·
2013-07-13 22:00
HDU
poj 2411 Mondriaan's Dream (
状态压缩dp
入门)
转载自http://blog.csdn.net/hopeztm/article/details/7841917这个题目类属于
状态压缩DP
,对于
状态压缩DP
,其实最简单的理解就是把状态用比特位的形式表示出来
H_R_D_127
·
2013-07-13 19:00
poj2288 Islands and Bridges
状态压缩dp
J- IslandsandBridgesTimeLimit:4000MS MemoryLimit:65536KB 64bitIOFormat:%I64d&%I64uSubmit StatusDescriptionGivenamapofislandsandbridgesthatconnecttheseislands,aHamiltonpath,asweallknow,isapatha
u010422038
·
2013-07-12 20:00
and
Islands
poj2288
CF 327E(Axis Walking-
状态压缩Dp
-lowbit的使用)
E.AxisWalkingtimelimitpertest3secondsmemorylimitpertest512megabytesinputstandardinputoutputstandardoutputIahubwantstomeethisgirlfriendIahubina.Theybothlivein Ox axis(thehorizontalaxis).Iahublivesatpo
·
2013-07-05 22:00
axis
CF 327E(Axis Walking-
状态压缩Dp
-lowbit的使用)
E.AxisWalkingtimelimitpertest3secondsmemorylimitpertest512megabytesinputstandardinputoutputstandardoutputIahubwantstomeethisgirlfriendIahubina.Theybothlivein Ox axis(thehorizontalaxis).Iahublivesatpoi
nike0good
·
2013-07-05 09:00
poj3254 - Corn Fields(
状态压缩dp
)
所谓的状态压缩就是把庞大的状态家族精简化。大多数都是用二进制表示状态的。状态:dp[i][j]表示第i行第j个状态所能达到的最大方案数目。状态转移:dp[i][j]+=dp[i-1][k]代码如下:#include #include #defineM1000 #defineN15 #defineMOD100000000 boola[N][N]; intm,n,dp[N][M],v[M]; void
shankeliupo
·
2013-06-18 20:00
状压dp hdu-4529-郑厂长系列故事——N骑士问题
解题思路:
状态压缩dp
.dp[i][j][p][q]:表示第i行状态为q(q写成二进制时,1表示放骑士,0表示不放骑士),第i-1行状态为p,并且前i行总的骑士的个数为j时总的方案总数。
cc_again
·
2013-06-08 23:00
hdu 4568 dij+TSP
blog.csdn.net/azheng51714/article/details/8166632 有n个城市,规定m个城市必须去,求最短时间花费 每到一个城市要休息a[i]时间,先dij求得各点的最短距离,然后
状态压缩
azheng51714
·
2013-06-03 20:00
MUTC 2 A - Hero
状态压缩dp
HeroTimeLimit:6000/3000MS(Java/Others) MemoryLimit:65536/65536K(Java/Others)TotalSubmission(s):1869 AcceptedSubmission(s):868ProblemDescriptionWhenplayingDotAwithgod-likerivalsandpig-liketeamme
cyendra
·
2013-06-01 16:00
题解
dp
Lost's revenge hdu3341
AC自动机+
状态压缩DP
,由于时限卡的比较死,进制高低位的选择不同可能会导致TLE(o(╯□╰)o),详细见注释#include #include #include #include #include
gyarenas
·
2013-05-23 13:00
UVa10651 Pebble Solitaire
很像跳棋)
状态压缩DP
load……
yew1eb
·
2013-05-18 17:00
hdu 3247 Resource Archiver
由n的范围1-10,很容易想到是用
状态压缩dp
去接字符串,关键是怎么定义状态,这里我就把我的状态定义先给出来,用dp[i][j]表示j状态,以第i个字符串结尾的最小长度。
No__stop
·
2013-05-17 15:00
poj 1185 炮兵阵地 (
状态压缩dp
)
题目链接 如果你是刚刚开始做
状态压缩dp
,我建议你先看看poj3254CornFields这是一道比这一题更简单,更容易入门的题目。
xindoo
·
2013-05-08 20:00
状态压缩dp
poj 3254 Corn Fields (
状态压缩dp
)
状态压缩dp
其实就是用二进制来表示所有的状态,比如这题,我们在某一行可以这样取0101101,用1代表取了,0代表没取,因为这点,它的数据量也限制在20以内,所有看到这样数据量的题目可以先考虑一下
状态压缩
xindoo
·
2013-05-07 20:00
动态规划
状态压缩dp
长沙理工组队赛 第二场 只A出来五道题目,银牌最后一名。。。伤不起!!!
A题:
状态压缩dp
??枚举两行???反正四个小时的比赛,没怎么敢写。。。毕竟好久没有写那个方面的题目了!!也未必能写出来。。C题:数列。。。
azheng51714
·
2013-05-07 10:00
POJ 3311 Hie with the Pie -- TSP
状态压缩dp
/* http://poj.org/problem?id=3311HiewiththePie 旅行商问题,状态压缩的dp */ #include #include #include #include #include #include usingnamespacestd; #defineCLR(c,v)memset(c,v,sizeof(c)) template _TMax(_Ta,_Tb){
x314542916
·
2013-05-06 23:00
UVa 10911 - Forming Quiz Teams
状态压缩dp
4th IIUC Inter-University ProgrammingContest,2005GFormingQuizTeamsInput:standardinputOutput:standardoutputProblemsetter: SohelHafizYouhavebeengiventhejobofformingthequizteamsforthenext‘MCACPCIQuizCham
cyendra
·
2013-05-04 20:00
题解
dp
[置顶] ACM知识点分类
第一类:基础算法(1)基础算法:枚举,贪心,递归,分治,递推,构造,模拟(2)动态规划:背包问题,树形dp,
状态压缩dp
,单调性优化,插头dp(3)搜索:dfs,bfs,记忆化搜索,优化与剪枝,双广,A
liujie619406439
·
2013-04-29 22:00
ACM
UVa 11795 - Mega Man's Mission
状态压缩dp
BMegaMan’sMissionsInputStandardInputOutputStandardOutput MegaManisofftosavetheworldagain.HisobjectiveistokilltheRobotscreatedbyDr.Wilywhosemotiveistoconquertheworld.Ineachmission,hewilltrytodestroyap
cyendra
·
2013-04-28 19:00
dp
动态规划
状态压缩DP
简单入门题 11题
1.每一行用一个二进制数表示,有些二进制数是题目中不合法的状态,我们可以预处理出一行合法状态,放在一个数组里面,在递推的过程中复杂度就会大大降低。POJ3254 CornFields codePOJ3311 HiewiththePie codeHDU4539 郑厂长系列故事――排兵布阵 codePOJ1185 炮兵阵地 code2.MST问题,dp[i]
c3568
·
2013-04-19 17:00
POJ 2411 Mondriaan's Dream 贴砖块类
状态压缩DP
入门
#include #include #include usingnamespacestd; #defineLLlonglong intn,m; LLdp[13][2666]; LLcnt; intx,M; voiddfs(inty,intpre,intnow){ if(y==m){ if(pre==M-1){ dp[x+1][now]+=cnt; //printf("x=%dcnt=%d\n",x
c3568
·
2013-04-19 17:00
ZOJ 3471 Most Powerful
状态压缩DP
#include #include usingnamespacestd; intmap[15][15]; intcst[11]={1,2,4,8,16,32,64,128,256,512,1024}; intdp[1200]; intMax(intx,inty) { returnx>y?x:y; } intmain() { intn,i,j,k,ans; while(1) { cin>>n; i
c3568
·
2013-04-19 17:00
POJ 2288 Islands and Bridges
状态压缩DP
#include #include #include usingnamespacestd; #defineLLlonglong intn,m; intv[14]; intmap[14][14]; intdp[8200][14][14]; LLcnt[8200][14][14]; intmain(){ inti,j,k,x,cas; scanf("%d",&cas); while(cas--){ s
c3568
·
2013-04-19 16:00
HDU 3001 Travelling
状态压缩DP
简单题
#include #include #include usingnamespacestd; constintinf=1000000009; intmap[13][13]; intcst[13]; intf[60004][13]; intdp[60004][13]; intn,m; voidinit(){ inti,j; cst[0]=1; for(i=1;i<=10;i++)cst[i]=cst[
c3568
·
2013-04-19 16:00
POJ 1185 炮兵阵地
状态压缩DP
简单题
#include #include #include usingnamespacestd; intstate[70],tot; intcnt[70]; intdp[103][66][66]; intn,m,M; voidinit(){ M=(1>1))continue; if(i&(i>>2))continue; state[tot++]=i; } memset(cnt,0,sizeof(cnt)
c3568
·
2013-04-19 16:00
HDU 4539
状态压缩DP
简单题
#include #include #include usingnamespacestd; intn,m,M; intstate[177],tot; intcnt[177]; intdp[103][177][177]; boolf1[177][177],f2[177][177]; boolok1(inta,intb){ if((state[a]>1)&state[b])return0; retur
c3568
·
2013-04-19 16:00
POJ 3311
状态压缩DP
简单题
#include #include #include usingnamespacestd; constintmod=100000000; intn,m,M; intstate[400],tot; inta[15]; boolf[400][400]; intdp[13][400]; voidadd(int&a,intb){ a+=b; if(a>=mod)a-=mod; } voidinit(){
c3568
·
2013-04-19 16:00
POJ 3254
状态压缩DP
简单题
#include #include #include usingnamespacestd; constintmod=100000000; intn,m,M; intstate[400],tot; inta[15]; boolf[400][400]; intdp[13][400]; voidadd(int&a,intb){ a+=b; if(a>=mod)a-=mod; } voidinit(){
c3568
·
2013-04-19 16:00
poj 1185 炮兵阵地
状态压缩dp
状态压缩dp
不过这个题目还是有很多要注意的地方。优化一先预处理出那些有用的状态。
yrleep
·
2013-04-14 19:00
HDU1074 Doing Homework
题目大意:给出n分homework,每份homework有截止时间以及需要做多少天,一份homework超出截止时间一天就罚一分,问怎么安排dohomework使得罚分最少 思路:第一次
状态压缩DP
.也很纠结
kg_second
·
2013-04-13 11:00
HDOJ 4529 - N骑士问题
状态压缩DP
状态压缩DP
果然比自己摸索出来的DP效率高多了...406ms..轻松飘过~~Program:#include #include #include #include #include #include
kk303
·
2013-04-12 15:00
POJ - 1185 跑兵阵地
状态压缩DP
状态压缩DP
...很简单了...一行最多10个...用1代表放炮兵..0代表不放...每行的状态最多1024种..并且还要合法..这样一来..一行的状态最多60种了...
kk303
·
2013-04-12 12:00
HDOJ - 4559 排兵布阵 DP
数据太弱..自己出了个100*10的全1输入来跑...N久才出来..真正完美的解法还是应该用
状态压缩DP
...Program:#include #include #include #include #include
kk303
·
2013-04-11 20:00
状态压缩DP
题目小节(三)
把最近做的一些
状态压缩DP
整理一下。DP苦手,从简单的开始。http://acm.zju.edu.cn/onlinejudge/showProblem.do?
dyx404514
·
2013-04-08 21:00
SGU 197
状态压缩DP
+矩阵乘法
看题n的数据,很明显告诉你了是矩阵乘法,且矩阵阶数为2^m。这里n要稍稍写一下高精度(减1,除以2)。用dp[i][j]表示前i层,最后层状态为j的合法个数。很容易推出方程。水水的题,速A#include #include #include #include usingnamespacestd; intn[103],m; constintN=1=mod)a-=mod; } voidmult(int
c3568
·
2013-04-05 00:00
SGU 131 贴地砖类型
状态压缩DP
用dp[i][j]表示要贴第i层时,第i-1层的状态,然后每一层dfs枚举一下情况即可dfs(x,y,pre,now)x层数y枚举的当前列pre前一层状态,now当前层状态根据当前列y的这位上pre和now状态,确定要贴的图形,注意贴的时候now层必须要有占一个位置,还要注意贴完以后pre层必须满状态。1.在贴的过程中处理必须优先把pre层贴满。2.或者贴好以后加个满pre层的条件也可以。状态转移
c3568
·
2013-04-04 13:00
状态压缩DP
题目小节(二)
最近做的
状态压缩DP
小节:http://acm.zju.edu.cn/onlinejudge/showProblem.do?
dyx404514
·
2013-04-04 10:00
状态压缩DP
题目小节 (一)
最近被
状态压缩DP
虐得不行,今天终于决定正视自己的弱项,好好把DP练习一下,把今天做的几道
状态压缩DP
总结一下,一定要想办法摆脱DP弱菜这个标签!!!http://poj.org/problem?
dyx404514
·
2013-04-03 10:00
状态压缩DP
树形D
状态压缩动态规划 动态规划的状态有时候比较难,不容易表示出来,需要用一些编码技术,把状态压缩的用简单的方式表示出来。典型方式:当需要表示一个集合有哪些元素时,往往利用2进制用一个整数表示。 *:一般有个数据n0){ if(x&1)num++; x>>=1; } returnnum; } *:然后就是DP部分了,明确好状态转移方程。先特殊处
liuqiyao_01
·
2013-04-02 16:00
dp
ACM
状态压缩dp
树形DP
hdu 4336 Card Collector 概率DP
状态压缩DP
做法:直接状态压缩了,如果理解了条件期望,那这道题目就可以迎刃而解这里要求的不是期望,而是求期望/概率#include #include constintLMT=1=0;i--) { tem=0.0; dp[i]++; for(j=0;j
cqlf__
·
2013-03-30 19:00
zoj 动态规划分类
动态规划 解#1100经典,
状态压缩DP
,要先枚举出行全部可能的状态,DP[i][j]表示i层,j末状态,dp[i][st[j][1]]+=dp[i-1][st[j][0]];#1425交叉线匹配,经典
yan_____
·
2013-03-21 21:00
POJ 3411 Paid Roads
思路:1.
状态压缩DP
。用dp[ i][j]表示在i状态下到达j城市的最小收费,其中i用二进制形式表示所有城市的访问情况。2.
biboyouyun
·
2013-03-10 23:00
动态规划
poj
ZOJ 2297 Survival
状态压缩DP
做法:这种元素个数很少,而且状态和顺序有关,可以往状态压缩上考虑#include #include constintLMT=1b?a:b; } intmin(inta,intb) { returna=c[j]) { dp[i|(1<<(j-1))]=max(dp[i|(1<<(j-1))],dp[i]+r[j]-c[j]); dp[i|(1<<(j-1))]=min(dp[i|(1<<(j-1))
cqlf__
·
2013-03-06 20:00
HDOJ 1693
给定N*M的矩阵,里面有些有树,有些没树(用0表示),问有多少种方法,通过任意个不交叉环路把树全连起来(就是哈密顿回路或者多个哈密顿回路覆盖所有非0数)题解:插头DP入门题,实际上,感觉插头DP也就是
状态压缩
tmeteorj
·
2013-02-26 17:00
Codeforces Beta Round #11, problem: (D) A Simple Task
状态压缩DP
+记忆化搜素DP
题意:在图中找简单回路/************* 看了大神的博客才有所感悟啊,记忆化搜索+状态压缩。。。。太神了... 这种复杂度,近百万的DFS复杂度居然没有TLE,果然经验不足,菜鸟一只。 用状态压缩枚举起点和可能经过的点。 可以判定的简单通路i->j,存在的条数为sum(i->k)其中k,j之间有边。 当然,每次计算通路个数的时候,可以借每一个k来判断回路的条数,当然只能算一次。 这样加出
cqlf__
·
2013-02-25 13:00
上一页
17
18
19
20
21
22
23
24
下一页
按字母分类:
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
其他