题目链接

 #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. 20145239杜文超 《Java程序设计》第3周学习总结

    20145239 <Java程序设计>第3周学习总结 教材学习内容总结 一.第四章: (1)对象和类: 使用Java撰写程序几乎都在使用对象,要产生对象必须先定义类,类是对象的设计图,对象 ...

  2. 使用libcurl,根据url下载对应html页面

    1. [图片] Capture.JPG ​2. [代码]GetPageByURL //static member variable definestring GetPageByURL::m_curPa ...

  3. kvm初体验之五:vm连接网络的两种方式:bridge和nat

    1. 在安装vm时指定网络连接方式 1)bridge virt-install --name vm1 --ram=1024 --vcpus=1 --disk path=/vm-images/vm1,s ...

  4. haproxy透传用户ip-方法和原理

    为了透传用户ip到后端server, proxy机器需要解决两个问题: 1.在创建到后端server的套接字时, 将用户ip作为套接字的源ip,从而让后端server看到: 2.后端server在回包 ...

  5. linux 命令:crontab

    一.crond简介 crond 是linux下用来周期性的执行某种任务或等待处理某些事件的一个守护进程,与windows下的计划任务类似,当安装完成操作系统后,默认会安装此服务 工具,并且会自动启动c ...

  6. physoft.net网站暂停 www.physoft.cn 正式开通 (菲烁科技, physoft)

    physoft.net原本计划以开源代码为主体,由于各种原因代码未能开源.基于这些代码,physoft成立了 菲烁(重庆)科技有限公司 ( www.physoft.cn) ,专注于工业级双目视觉测量, ...

  7. [C++11新特性]第二篇

    0.可变数量参数,可变函数模版,变长模版类 c++98可变数量参数 #include<cstdio> #include<cstdarg> double SumOfFloat(i ...

  8. asterisk ss7 ${CALLERID(rdnis)}变量为空问题

    asterisk 1.8.16+chan_ss7 version 2.1.1b ${CALLERID(rdnis)}变量取不到信息问题,解决 编辑 funcs/func_callerid.c chan ...

  9. jmeter的http post请求与测试Java请求

    1.jmeter 测试Java请求 1.1 建立测试类,在被测程序中添加测试类 1.2 将测试程序打包,打成不可运行的包 1.3 将打好的包,放在$JMETER_HOME/lib/exts下面,把测试 ...

  10. Python3解leetcode Symmetric Tree

    问题描述: Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). ...