玉米田Corn Fields
传送门
#include <cstdio> #include <cmath> #include <cstring> #include <algorithm> using namespace std; #define ll long long #define re register const int mod=1e8; void read(int &a) {a=0;int d=1;char ch;while(ch=getchar(),ch>'9'||ch<'0')if(ch=='-')d=-1;a=ch^48;while(ch=getchar(),ch>='0'&&ch<='9')a=(a<<3)+(a<<1)+(ch^48);a*=d; } int cnt,sta[505],f[15][1<<12+1],st[505]; inline bool solve(int x){return x&(x>>1);} int main() {int n,m;read(n);read(m);for(re int i=1;i<=n;i++)for(re int j=1;j<=m;j++){int x;read(x);if(!x)st[i]|=1<<(m-j);}int h=(1<<m)-1;for(re int i=0;i<=h;i++){if(solve(i))continue;sta[++cnt]=i;}for(re int i=1;i<=cnt;i++){if(st[1]&sta[i])continue;f[1][i]=1;}for(re int i=2;i<=n;i++)for(re int j=1;j<=cnt;j++){int last=sta[j];if(last&st[i-1])continue;for(re int k=1;k<=cnt;k++){int now=sta[k];if(now&st[i])continue;if(now&last)continue;(f[i][k]+=f[i-1][j])%=mod;}}int ans=0;for(re int i=1;i<=cnt;i++)(ans+=f[n][i])%=mod;printf("%d",ans);return 0; }
转载于:https://www.cnblogs.com/acm1ruoji/p/10859795.html
玉米田Corn Fields相关推荐
- 洛谷P1879 [USACO06NOV]玉米田Corn Fields【状压dp】
P1879 [USACO06NOV]玉米田Corn Fields 时间限制 1.00s 内存限制 125.00MB 题目描述 Farmer John has purchased a lush new ...
- 洛谷P1879 [USACO06NOV]玉米田Corn Fields
P1879 [USACO06NOV]玉米田Corn Fields 题目描述 Farmer John has purchased a lush new rectangular pasture compo ...
- [USACO06NOV]玉米田Corn Fields题解
[USACO06NOV]玉米田Corn Fields题解 --HM 题目描述 农场主John新买了一块长方形的新牧场,这块牧场被划分成M行N列(1 ≤ M ≤ 12; 1 ≤ N ≤ 12),每一格都 ...
- 刷题周记(九)——#状压DP:最短Hamilton路径、小国王(互不侵犯)、玉米田(Corn Fields G)、愤怒的小鸟、吃奶酪、炮兵阵地、宝藏 #区间DP:清空字符串#DP:关灯问题II
文章目录 --2020年12月20日(周日)------------------ 状压DP 一.最短Hamilton路径(模板题) 二.玉米田(P1879 [USACO06NOV]Corn Field ...
- [USACO06NOV]玉米田Corn Fields(动态规划,状态压缩)
题目描述 Farmer John has purchased a lush new rectangular pasture composed of M by N (1 ≤ M ≤ 12; 1 ≤ N ...
- 洛谷 P1879 [USACO06NOV]玉米田Corn Fields
题目描述 Farmer John has purchased a lush new rectangular pasture composed of M by N (1 ≤ M ≤ 12; 1 ≤ N ...
- jzoj1266,P1879-[USACO06NOV]玉米田Corn Fields【状态压缩,dp】
正题 评测记录:https://www.luogu.org/recordnew/lists?uid=52918&pid=P1879 大意 有n*m的矩阵,有些地方可以放,有些不可以放,不可以相 ...
- [USACO06NOV]玉米田Corn Fields (状压$dp$)
题目链接 Solution 状压 \(dp\) . \(f[i][j][k]\) 代表前 \(i\) 列中 , 已经安置 \(j\) 块草皮,且最后一位状态为 \(k\) . 同时多记录一个每一列中的 ...
- [USACO06NOV]玉米田Corn Fields
题目 https://www.luogu.org/problemnew/show/P1879 思路 用状态表示草地最外层,转移时按状态判断 代码 #include<cstdio> usin ...
最新文章
- 解决SpringMVC中的 Could not find acceptable represent
- Spring Boot -Shiro配置多Realm
- wordpress增删改查
- Office 365系列之八:配置和体验Exchange和Lync
- jdi屏幕斜纹_荣耀V10屏幕有斜纹问题,有人甚至因此退货,真的这么严重?
- android aapt 用法 -- ApkReader
- NB-IoT移远BC95调试笔记 01 加网测试
- mac安装win7之后鼠标失灵_苹果电脑安装win7时键盘鼠标无响应3种解决方案
- IE6 浏览器常见兼容问题
- 网线水晶头制作的线序
- 电脑网线水晶头接法图解
- 强大如斯的Bunch类
- \t\t【团队精神】荣辱与共 交流分享 精诚协作 尊重理解 ——程序员应知
- iphone之Info.plist的属性
- 数据结构与算法学习(第一天)
- esp32 micropython 控制ws2812 RGB灯带
- [cocos2dx开发技巧4]工具CocosBuilder的使用--复杂动画
- c语言“递归系列”:递归实现x的n次方
- springboot集成elasticsearch6.8.23设置密码xpack连接,及遇到的None of the configured nodes are available
- 爽啊!写了一个网页:首字母索引的单词(十分垃圾,简单的不得了)
热门文章
- ORACLE建表练习
- javascript里面RegExp的exec函数的总结
- markdown 使用
- ubuntu 目录结构
- WEB安全,SQL注入漏洞的加固代码汇总
- 西班牙放大招,利用区块链技术防腐
- 区块链4.0DexChain是什么?
- 统计数字,空白符,制表符_为什么您应该在HTML中使用制表符空间而不是多个非空白空间(nbsp)...
- 快速 开发平台 架构_快速介绍清洁架构
- 谢尔盖.布林的早期思想_谷歌联合创始人谢尔盖·布林(Sergey Brin)谈人工智能与自动化...