poj 2411 状态压缩dp
来源:互联网 发布:finale 2016 mac 编辑:程序博客网 时间:2024/05/21 19:39
横的看成11,竖的看成0/1,
1.相邻2行之间是否冲突就是看a|b是否全是1。
2.同一行是否冲突就是看横着的1的个数是否是奇数。
#include<cstdio>#include<cstring>#include<algorithm>#include<vector>#include<iostream>using namespace std;long long dp[15][1<<12];int ok[1<<12];bool isok(int sta){ int tot=0; while(sta) { if(sta&1) { tot++; sta>>=1; if(sta&1) {sta>>=1;tot++;} else return false; } else sta>>=1; } return !(tot&1);}int main(){ int n,m; int top=(1<<11)-1; for(int i=0;i<=top;i++) ok[i]=isok(i); while(~scanf("%d%d",&n,&m)&&(n||m)) { top=(1<<m)-1; memset(dp,0,sizeof(dp)); for(int i=0;i<=top;i++) if(ok[i]) dp[1][i]=1; for(int i=2;i<=n;i++) { for(int j=0;j<=top;j++) { for(int k=0;k<=top;k++) { if((k|j)==top&&ok[k&j]) dp[i][j]+=dp[i-1][k]; } } } cout<<dp[n][top]<<endl; } return 0;}
4 0
- poj-2411-状态压缩DP
- poj 2411 状态压缩dp
- poj 2411 状态压缩DP
- POJ 2411 状态压缩DP
- poj 2411 状态压缩dp
- poj 2411 状态压缩dp
- POJ 2411 状态压缩DP
- POJ 2411 状态压缩DP
- poj 2411 (状态压缩dp)
- poj 2411 状态压缩dp
- POJ 2411 状态压缩DP
- poj 2411 状态压缩DP 铺砖块
- poj 2411 状态压缩dp+轮廓线
- POJ 2411 铺地砖 状态压缩dp入门
- poj 2411(状态压缩DP) zoj 1100
- poj 2411(状态压缩dp)
- 【状态压缩DP】POJ 1170
- 【状态压缩DP】POJ 1185
- 如何知道某个java类从哪个位置加载?
- java.util.map中的方法entrySet解析
- Linux 下编译安装OpenCV
- 银行调度系统
- nodejs的require的用法
- poj 2411 状态压缩dp
- JDK5新特性
- Linux之V4L2基础编程
- 多线程
- 5
- 面向对象
- iOS开发笔记之多点触控(四) 可靠的多点触控,为每个View分配唯一触摸对象
- 二叉查找树的简单实现
- Java知识点总结