题目链接

 #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(模板)的更多相关文章

  1. POJ 3254. Corn Fields 状态压缩DP (入门级)

    Corn Fields Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9806   Accepted: 5185 Descr ...

  2. 【BZOJ1725】[Usaco2006 Nov]Corn Fields牧场的安排 状压DP

    [BZOJ1725][Usaco2006 Nov]Corn Fields牧场的安排 Description Farmer John新买了一块长方形的牧场,这块牧场被划分成M列N行(1<=M< ...

  3. poj 3254 Corn Fields

    http://poj.org/problem?id=3254 Corn Fields Time Limit: 2000MS   Memory Limit: 65536K Total Submissio ...

  4. Corn Fields——POJ3254状态压缩Dp

    Corn Fields Time Limit: 2000MS Memory Limit: 65536K Description Farmer John has purchased a lush new ...

  5. poj3254 Corn Fields (状压DP)

    http://poj.org/problem?id=3254 Corn Fields Time Limit: 2000MS   Memory Limit: 65536K Total Submissio ...

  6. POJ 3254 Corn Fields(状态压缩DP)

    Corn Fields Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 4739   Accepted: 2506 Descr ...

  7. 状压DP POJ 3254 Corn Fields

    题目传送门 /* 状态压缩DP:先处理硬性条件即不能种植的,然后处理左右不相邻的, 接着就是相邻两行查询所有可行的种数并累加 写错一个地方差错N久:) 详细解释:http://www.tuicool. ...

  8. POJ 3254 Corn Fields(状压DP)

    Corn Fields Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 13732   Accepted: 7216 Desc ...

  9. BZOJ1725: [Usaco2006 Nov]Corn Fields牧场的安排

    1725: [Usaco2006 Nov]Corn Fields牧场的安排 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 400  Solved: 290 ...

随机推荐

  1. haproxy 修改 访问路径

    # 匹配 jsessionid,并去除 jessionid参数reqrep ^([^\ :]*)\ /a/test.html;jsessionid=.*\?(.*) \1\ /b/test.html? ...

  2. python的try...except

    try/except与其他语言相同,在python中,try/except语句主要是用于throw程序正常执行过程中出现的异常,如语法错(python作为脚本语言没有编译的环节,在执行过程中对语法进行 ...

  3. PHP按照比例随机

    有这样的需求,在打开链接的时候,随机(按照项目的某个属性的比例随机)跳转到指定的几个项目的某一个项目页面 比如项目A:80  项目B:20 那么跳转到项目A 的比例为80%,项目B的比例为20% 那么 ...

  4. 英语影视台词---无敌破坏王2大脑互联网(3)((Ralph)我们去喝根汁汽水吧)

    英语影视台词---无敌破坏王2大脑互联网(3)((Ralph)我们去喝根汁汽水吧) 一.总结 一句话总结: Let's go get a root beer. 1.(Ralph)让我来瞧瞧你的本事  ...

  5. hdu-1542 Atlantis(离散化+线段树+扫描线算法)

    题目链接: Atlantis Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/32768 K (Java/Others) ...

  6. HDU-6035:Colorful Tree(虚树+DP)

    这里有三道长得像的题: 一:HDU6036: There is a tree with nn nodes, each of which has a type of color represented ...

  7. JSP 使用<%@include%>报Duplicate local variable path 错误 解决方法

    错误提示:Multiple annotations found at this line:- Duplicate local variable path- Duplicate local variab ...

  8. codevs2189数字三角形w——最优性转化

    题目:http://codevs.cn/problem/2189/ 通过增加一维,将最优性转化为可行性. 代码如下: #include<iostream> #include<cstd ...

  9. 连续4个小时ping不通远端主机,则本机关机

    #!/bin/bash #连续4个小时ping不通远端主机,则本机关机. begin_time=$(date "+%s") while true;do sleep 2 ping - ...

  10. jquery中对于批量deferred的处理

    此代码仿照jquery源码中$.when()的实现 function test(i) { var dfd = $.Deferred(); if(i%2 == 0) { console.log(&quo ...