PKU 2411 Mondriaan's Dream 状态DP
以前做过这题,今天又写了一次,突然发现写了一个好漂亮的DFS……(是不是太自恋了 - -#)
代码:
#include <cstdio>
#include <cstring>
#include <algorithm> using namespace std; typedef __int64 ll; int n, m;
ll dp[][<<]; void dfs(int turn, int now, int next, int cnt) {
if (cnt > n) return ;
if (cnt==n) {
dp[turn+][next] += dp[turn][now];
return ;
}
if (!(now&(<<cnt))) { //如果cnt格没放,那就必须放
dfs(turn, now, next|(<<cnt), cnt+); //放一个竖着的
if (!(now&(<<(cnt+))) && (cnt<n-)) dfs(turn, now, next, cnt+); //放一个横着的
} else dfs(turn, now, next, cnt+); //如果这格被上一层的占了,那这一格就不能放任何东西
} int main() {
#ifdef Phantom01
freopen("PKU2411.txt", "r", stdin);
#endif // Phantom01 while (scanf("%d%d", &n, &m)!=EOF) {
if (n==&&m==) return ; if ((n*m)&) {
puts("");
continue;
}
memset(dp, , sizeof(dp));
dp[][] = ;
for (int i = ; i < m; i++)
for (int j = ; j < (<<n); j++) if (dp[i][j])
dfs(i, j, , );
printf("%I64d\n", dp[m][]);
}
}
PKU2411
PKU 2411 Mondriaan's Dream 状态DP的更多相关文章
- POJ 2411 Mondriaan's Dream 插头dp
题目链接: http://poj.org/problem?id=2411 Mondriaan's Dream Time Limit: 3000MSMemory Limit: 65536K 问题描述 S ...
- poj 2411 Mondriaan's Dream(状态压缩dP)
题目:http://poj.org/problem?id=2411 Input The input contains several test cases. Each test case is mad ...
- poj 2411 Mondriaan's Dream 轮廓线dp
题目链接: http://poj.org/problem?id=2411 题目意思: 给一个n*m的矩形区域,将1*2和2*1的小矩形填满方格,问一共有多少种填法. 解题思路: 用轮廓线可以过. 对每 ...
- PKU P2411 Mondriaan's Dream
PKU P2411 Mondriaan's Dream 题目描述: Squares and rectangles fascinated the famous Dutch painter Piet Mo ...
- HDU 1400 (POJ 2411 ZOJ 1100)Mondriaan's Dream(DP + 状态压缩)
Mondriaan's Dream Problem Description Squares and rectangles fascinated the famous Dutch painter Pie ...
- Poj 2411 Mondriaan's Dream(压缩矩阵DP)
一.Description Squares and rectangles fascinated the famous Dutch painter Piet Mondriaan. One night, ...
- POJ 2411 Mondriaan's Dream -- 状压DP
题目:Mondriaan's Dream 链接:http://poj.org/problem?id=2411 题意:用 1*2 的瓷砖去填 n*m 的地板,问有多少种填法. 思路: 很久很久以前便做过 ...
- Poj 2411 Mondriaan's Dream(状压DP)
Mondriaan's Dream Time Limit: 3000MS Memory Limit: 65536K Description Squares and rectangles fascina ...
- POJ 题目2411 Mondriaan's Dream(状压DP)
Mondriaan's Dream Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 13519 Accepted: 787 ...
随机推荐
- jQuery学习(五)——使用JQ完成复选框的全选和全不选
1.在系统后台进行人员管理时,进行批量删除,使用jq完成全选和全不选 步骤分析: 第一步:引入jquery文件 第二步:书写页面加载函数 第三步:为上面的复选框绑定单击事件 第四步:将下面所有的复选框 ...
- iOS系统的特点-iOS为什么运行更流畅
1.进程管理机制-不允许后台进程: 2.用户事件响应优先级: 3.GPU加速: 4.系统内存管理机制: 5.运行机制-机器码直接运行-非虚拟机.
- ActiveMQ学习笔记(7)----ActiveMQ支持的传输协议
1. 连接到ActiveMQ Connector: Active提供的,用来实现连接通讯的功能,包括:client-to-broker,broker-to-broker.ActiveMQ允许客户端使用 ...
- [USACO10NOV]奶牛的图片Cow Photographs 树状数组 递推
Code: #include<cstdio> #include<algorithm> #include<string> #include<cstring> ...
- axios的坑
1.axios默认发送application/json 格式 https://www.cnblogs.com/qdcnbj/p/8143155.html 资料: https://www.npmjs.c ...
- Java取得环境变量和系统属性
取得所有的环境变量 public class GetEnvAndProp { public static void main(String[] args) { Map<String, Strin ...
- JavaScript函数写法整理
1.普通函数定义的两种写法 function hello(){ console.log("hello!"); } var hello = function(){ console.l ...
- 紫书 习题 8-25 UVa 11175 (结论证明)(配图)
看了这篇博客https://blog.csdn.net/u013520118/article/details/48032599 但是这篇里面没有写结论的证明, 我来证明一下. 首先结论是对于E图而言, ...
- docker mysql 文件挂载和MySQL字符集设置
原文:docker mysql 文件挂载和MySQL字符集设置 docker run -p 3306:3306 --name mysql -v /usr/local/mysql/my.cnf:/etc ...
- openSessionInView的使用原理及性能分析
看到好多项目中用到了openSessionInView,这种做法无非是开发方便,能够在JSP页面中操作数据库层方面的业务. 下边说下openSessionInView的使用方法及性能问题. 使用: 1 ...