博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[Hdu1693]Eat the Trees(插头DP)
阅读量:7261 次
发布时间:2019-06-29

本文共 790 字,大约阅读时间需要 2 分钟。

Description

题意:在n*m(1<=N, M<=11 )的矩阵中,有些格子有树,没有树的格子不能到达,找一条或多条回路,吃完所有的树,求有多少种方法。

Solution

插头DP入门题,\(dp[i][j][k]\)表示\(G_{i,j}\)且轮廓线状态为\(k\)时的方案数

转移有6种,

Code

#include 
#include
#include
#define N 14#define ll long longusing namespace std;int T,n,m,g[N][N];ll dp[N][N][1<
'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f;}int main(){ T=read(); for(int ca=1;ca<=T;++ca){ memset(g,0,sizeof(g)); memset(dp,0,sizeof(dp)); n=read(),m=read(); for(int i=1;i<=n;++i)for(int j=1;j<=m;++j)g[i][j]=read(); dp[0][m][0]=1; for(int i=1;i<=n;++i){ for(int j=0;j<(1<

转载于:https://www.cnblogs.com/void-f/p/8150043.html

你可能感兴趣的文章
redis介绍和数据类型
查看>>
java基础之访问修饰符protected
查看>>
杨泽业:给你的wordpress博客添加SMTP邮件服务,评论以后邮件通知
查看>>
在 Hadoop 中使用 Python 进行统计开发
查看>>
wordpress的安装
查看>>
win7 32位open***安装后,无法使用故障报错.
查看>>
SQL语言(一)
查看>>
Web性能优化的完整资料汇总
查看>>
IOS OC 向前声明 forward declaring
查看>>
SQL Server 系统表简介
查看>>
linux文档打包,压缩,解压缩常用指令介绍(tar gzip bzip2)
查看>>
用mappedbytebuffer实现一个持久化队列
查看>>
ExtJS4.2实例:含下拉列表(Combobox)的表格(Grid)
查看>>
用TortoiseGit在push代码到git@osc时不用输入帐号和密码
查看>>
Ethernet Management Interface VRF
查看>>
我的友情链接
查看>>
vysper + psi JABBER SEARCH 测试
查看>>
UIView常用的一些方法小记之setNeedsDisplay和setNeedsLayout
查看>>
我的友情链接
查看>>
使用OpManager监控AIX
查看>>