Corn Fields(模板)
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <iostream>
using namespace std;
typedef long long ll; inline int read()
{
int x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
} /********************************************************************/ const int mod = ;
const int maxn = ;
int n, m;
int dp[][(<<)+];
int a[maxn]; int line(int x, int y){
if((a[x]&y) != y) return ;
if((y&(y<<)) != ) return ;
return ;
} int main(){
int n,m;
while(~scanf("%d%d",&n,&m)){
for(int i=;i<=n;i++){
a[i]=;
for(int j=;j<=m;j++){
int t;
scanf("%d",&t);
a[i]=(a[i]<<)+t;
}
}
memset(dp,,sizeof(dp));
dp[][] = ;
for(int i = ;i <= n;i++){
for(int j=;j<(<<m);j++){
if(line(i,j)==)continue;
for(int k=;k<(<<m);k++){
if((j&k)==){
dp[i][j]=dp[i][j]+dp[i-][k];
dp[i][j]%=mod;
}
}
}
}
int ans = ;
for(int i = ;i < (<<m);i++){
ans= (ans + dp[n][i] )%mod;
}
printf("%d\n",ans);
}
}
Corn Fields(模板)的更多相关文章
- POJ 3254. Corn Fields 状态压缩DP (入门级)
Corn Fields Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 9806 Accepted: 5185 Descr ...
- 【BZOJ1725】[Usaco2006 Nov]Corn Fields牧场的安排 状压DP
[BZOJ1725][Usaco2006 Nov]Corn Fields牧场的安排 Description Farmer John新买了一块长方形的牧场,这块牧场被划分成M列N行(1<=M< ...
- poj 3254 Corn Fields
http://poj.org/problem?id=3254 Corn Fields Time Limit: 2000MS Memory Limit: 65536K Total Submissio ...
- Corn Fields——POJ3254状态压缩Dp
Corn Fields Time Limit: 2000MS Memory Limit: 65536K Description Farmer John has purchased a lush new ...
- poj3254 Corn Fields (状压DP)
http://poj.org/problem?id=3254 Corn Fields Time Limit: 2000MS Memory Limit: 65536K Total Submissio ...
- POJ 3254 Corn Fields(状态压缩DP)
Corn Fields Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 4739 Accepted: 2506 Descr ...
- 状压DP POJ 3254 Corn Fields
题目传送门 /* 状态压缩DP:先处理硬性条件即不能种植的,然后处理左右不相邻的, 接着就是相邻两行查询所有可行的种数并累加 写错一个地方差错N久:) 详细解释:http://www.tuicool. ...
- POJ 3254 Corn Fields(状压DP)
Corn Fields Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 13732 Accepted: 7216 Desc ...
- BZOJ1725: [Usaco2006 Nov]Corn Fields牧场的安排
1725: [Usaco2006 Nov]Corn Fields牧场的安排 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 400 Solved: 290 ...
随机推荐
- u盘安装debian 7(Wheezy) stabe
将一个闲置u盘插入电脑usb口.从http://mirrors.sohu.com/debian-cd/7.4.0/amd64/iso-dvd/debian-7.4.0-amd64-DVD-1.iso ...
- MVC+Ext.net零基础学习记录(二)
很多人在开发一个新的项目时,需要先决定项目的整体架构,是决定使用MVC的同时也不例外,具体包含:项目的多语言性,项目的多风格选择,项目的可扩展性 其中项目的多语言性:http://www.cnblog ...
- HDU2296 Ring —— AC自动机 + DP
题目链接:https://vjudge.net/problem/HDU-2296 Ring Time Limit: 2000/1000 MS (Java/Others) Memory Limit ...
- linux应用之jdk环境的安装(centos)
一.yum安装 1.执行:yum search jdk 已加载插件:fastestmirror, securityLoading mirror speeds from cached hostfile ...
- UC Bug
出现bug时,假如把A代码段删了,bug消失,那么此bug是不是一定就是A代码段导致的呢?接着写B代码段,同样bug再现,那么此bug是不是一定就是B代码段导致的呢? 未必,可能是Base代码段和A. ...
- oracle 11g 常用命令
sqlplus system/123@ORCL; 查看oracle字符集: select * from nls_database_parameters where parameter ='NLS_CH ...
- HihoCoder1672 : 区间问题([Offer收割]编程练习赛41)(贪心)
时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 给定N个区间[Ai, Bi],请你找到包含元素最少的整数集合S,使得每个区间都至少有两个整数在S中. 例如给定三个区间[1 ...
- C#支持从自定义日期时间格式到DateTime类型
/// <summary> /// /// </summary> /// <param name=&quo ...
- WPF GridViewColumn Sort DataTemplate
wpf的GridViewColumn的排序要用到ICollectionView 的SortDescriptions. SortDescriptions数组里是 SortDescription, S ...
- JSON 的正确用法:Python、MongoDB、JavaScript与AjaxJSON 的正确用法:Python、MongoDB、JavaScript与Ajax
本文主要总结网站编写以来在传递 JSON 数据方面遇到的一些问题以及目前采用的解决方案.网站数据库采用 MongoDB,后端是 Python,前端采用“半分离”形式的 Riot.js,所谓半分离,是说 ...