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 ...
随机推荐
- Dubbo之生产者
环境步骤: 安装Zookeepr启动 创建Maven项目搭建生产者和消费者 安装DubboAdmin平台,实现监控 Dubbo注册中心采用的是Zookeeper.为什么采用Zookeeper呢? Zo ...
- java调用shell命令及脚本
shell脚本在处理文本及管理操作系统时强大且简单,将shell脚本结合到应用程序中则是一种快速实现的不错途径本文介绍使用java代码调用并执行shell 我在 -/bin/ 目录下写了jbossLo ...
- 鸟哥的linux私房菜 - 第5/6/7/9章(在线求助 man page、Linux档案权限与目录配置、Linux档案与目录管理、压缩与打包)
第五章.在线求助 man page X window与文本模式的切换 Ctrl+Alt+F1~F6:文字接口登入tty1~tty6终端机: Ctrl+Alt+F7:图形接口桌面. 注销当前用户:exi ...
- centos7搭建mysql-5.7.22主从复制
mysql7.7.22主从复制 本项目是根据真实环境搭建编写出文档,文档中的目录也是根据自己公司环境所创建.公司原来是一台服务器搭建的数据库(5.7.22),由于业务的扩展需要搭建一台从服务器,减轻主 ...
- win7 jenkins搭建.Net项目自动构建
前提:操作系统win7, 确保需要的.NET Framework已经安装 1. 安装插件 Jenkins--系统管理局--管理插件--可选插件,搜索MSBuild Plugin并安装:重启tomcat ...
- codeforces 659F F. Polycarp and Hay(并查集+bfs)
题目链接: F. Polycarp and Hay time limit per test 4 seconds memory limit per test 512 megabytes input st ...
- PS 滤镜— —扇形warp
clc; clear all; close all; addpath('E:\PhotoShop Algortihm\Image Processing\PS Algorithm'); I=imread ...
- 机器学习 F1-Score, recall, precision
在机器学习,模式识别中,我们做分类的时候,会用到一些指标来评判算法的优劣,最常用的就是识别率,简单来说,就是 Acc=Npre/Ntotal 这里的 Npre表示预测对的样本数,Ntotal表示测试集 ...
- ASM认证与口令文件
ASM认证 ORACLE ASM 实例没有数据字典,所以连接ASM 实例只能通过如下三种系统权限来进行连接: SYSASM,SYSDBA,SYSOPER. 可以通过如下三种模式来连接ASM 实例:1. ...
- Redo Gap 处理与优化
理论背景 当redo data 传送发生中断时就会产生redo gap.当redo 传送恢复正常以后,redo transport service 会自动检测redo gap并发送缺失的redo 到d ...