USACO 2006 November Gold Corn Fields
USACO 2006 November Gold Corn Fields
题目描述:
Farmer John has purchased a lush new rectangular pasture composed of M by N square parcels. He wants to grow some yummy corn for the cows on a number of squares.
Regrettably, some of the squares are infertile and can't be planted. Canny FJ knows that the cows dislike eating close to each other, so when choosing which squares to plant, he avoids choosing squares that are adjacent; no two chosen squares share an edge. He has not yet made the final choice as to which squares to plant.
Being a very open-minded man, Farmer John wants to consider all possible options for how to choose the squares for planting. He is so open-minded that he considers choosing no squares as a valid option! Please help Farmer John determine the number of ways he can choose the squares to plant.
输入格式:
* Line 1: Two space-separated integers: M and N
* Lines 2..M+1: Line i+1 describes row i of the pasture with N space-separated integers indicating whether a square is fertile (1 for fertile, 0 for infertile)
输出格式:
* Line 1: One integer: the number of ways that FJ can choose the squares modulo 100,000,000.
样例输入:
2 3
1 1 1
0 1 0
样例输出:
9
提示:
【样例解释】
Number the squares as follows:
1 2 3
4
There are four ways to plant only on one squares (1, 2, 3, or 4),
three ways to plant on two squares (13, 14, or 34), 1 way to plant
on three squares (134), and one way to plant on no squares. 4+3+1+1=9.
【数据规模】
1<=M<=12;1<=N<=12
时间限制:1000ms
空间限制:256MByte
又水了一道题,地图记得反着存就好了。。。别忘了%%%kcz!!!
唉,最近kcz在玩pku的游戏挑战赛,我们这些小蒟蒻只有刷水题的份了,QAQ——
#include<bits/stdc++.h>
#define ll long long
#define kcz 100000000
using namespace std; ll f[][ << ] , m , n , maxn;
ll s [][]; ll check(ll now , ll down)
{
if((down << ) & down || (down >> ) & down) return ;
for(ll i=;i<m;i++)
{
ll ce = << i;
if(now & ce && down & ce) return ;
}
return ;
} ll find(ll pos , ll val)
{
for(ll i=;i<m;i++)
{
ll ce = << i;
if(val & ce && s[pos][i]) return ;
}
return ;
} int main(){
cin >> n >> m;
for(ll i=;i<=n;i++)
for(ll j=;j<m;j++)
{ scanf("%lld",&s[i][j]);
s[i][j] ^= ;
}
maxn = << m;
f[][] = ;
for(ll i=;i<n;i++)
for(ll j=;j<maxn;j++)
{
if(f[i][j])
{
for(ll k=;k<maxn;k++)
if(check(j , k) && find(i + , k))
f[i + ][k] += f[i][j];
}
}
ll ans = ;
for(ll i=;i<maxn;i++)
{
ans += f[n][i];
ans %= kcz;
}
cout << ans;
}
USACO 2006 November Gold Corn Fields的更多相关文章
- USACO 2006 November Gold Corn Fields /// 状压 oj23941
题目大意: 输入n m 接下来n行m列 0表示不能种玉米 1表示能 要求种玉米位置的上下左右四连通区域不能种玉米 输出方案数 Sample Input 2 31 1 10 1 0 Sample Out ...
- USACO 2006 November Gold
POJ 3253 Fence Repair STL堆操作 我想说,STL里堆是我目前见到最蛋疼的操作. #include <cstdio> #include <cstring> ...
- 【USACO 2006 November Gold】Corn Fields
[题目链接] 点击打开链接 [算法] 状压DP [代码] #include<bits/stdc++.h> using namespace std; #define MAXN 12 #def ...
- USACO 2006 November Gold Fence Repair /// 贪心(有意思)(优先队列) oj23940
题目大意: 输入N ( 1 ≤ N ≤ 20,000 ) :将一块木板分为n块 每次切割木板的开销为这块木板的长度,即将长度为21的木板分为13和8,则开销为21 接下来n行描述每块木板要求的长度Li ...
- 【usaco 2006 feb gold】 牛棚安排
终于自己独立做出来一道题QAQ然而本校数据实在太水不能确定我是不是写对了... 原题: Farmer John的N(1<=N<=1000)头奶牛分别居住在农场所拥有的B(1<=B&l ...
- [Poj3261] [Bzoj1717] [后缀数组论文例题,USACO 2006 December Gold] Milk Patterns [后缀数组可重叠的k次最长重复子串]
和上一题(POJ1743,上一篇博客)相似,只是二分的判断条件是:是否存在一段后缀的个数不小于k #include <iostream> #include <algorithm> ...
- USACO 2008 November Gold Cheering up the Cows /// MST oj24381
题目大意: 输入n,p:n个点,p条路 接下来n行输入c[]:在各个点需要花费的时间 接下来p行输入u,v,w:u点到v点的路需要花费时间w 求经过所有点且最后回到起点的最少花费时间 https:// ...
- POJ 3254. Corn Fields 状态压缩DP (入门级)
Corn Fields Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 9806 Accepted: 5185 Descr ...
- poj 3254 Corn Fields
http://poj.org/problem?id=3254 Corn Fields Time Limit: 2000MS Memory Limit: 65536K Total Submissio ...
随机推荐
- 红米note2 刷机 注意问题:
其他的百度都有,用刷线宝刷 红米note2 刷机 注意问题: 关机状态线下,链接电脑,按着音量下键不松手,按电源键开机后松开,即进入刷机模式. 其中,红米,红米1s移动,红米note移动3g/联通 ...
- Tclientdataset的CloneCursor问题 clientdataset 复制 赋值 的问题
http://www.myexception.cn/delphi/720245.html Tclientdataset的CloneCursor问题我的DBGRID所连接的数据源为cdsBook,然后用 ...
- GIt 工作区与暂存区
转载:https://www.liaoxuefeng.com/wiki/896043488029600/897271968352576 工作区与暂存区 工作区(Working Directory) 就 ...
- 【Unity Shader】---Alpha Blending的意义
Alpha Blending 即Alpha混合 Blending 就是处理透明度的,处理光栅化最后阶段,显示在屏幕上的颜色 1 Blend Off 关闭alpha混合 2 混合公式:Blend Src ...
- 配置OSPF认证
按照上图拓扑配置路由器的IP 配置完后测试直连网段连通性 搭建OSPF网络 注意是多区域的配置,R2是ABR 连着area0和area1 并且每个路由器的环回接口IP也要加进去 此时密码以明文方 ...
- css的继承之width属性(容易忽略)
众所周知,css的三大特性分别是 继承性,层叠性,和优先级. 那么这里就详细说一下css中width的继承性及其特殊情况. 继承性概念详解:css的继承性指的被包在内部的标签拥有外部标签的样式性,子元 ...
- 一个完整的http请求响应过程
一. HTTP请求和响应步骤 图片来自:理解Http请求与响应 以上完整表示了HTTP请求和响应的7个步骤,下面从TCP/IP协议模型的角度来理解HTTP请求和响应如何传递的. 二.TCP/IP协 ...
- python里的排序
本篇文章主要讲: 自定义规则排序 多字段排序 开讲之前,先讲一些简单sorted()或者sort(),两者返回值不同!大家自行学习,不是本文的重点! sorted([5, 2, 3, 1, 4]) # ...
- python 导入re模块语法及规则
正则表达式是功能比较强大的模块,应用在很多地方,抓网页,数据分析,数据验证等,下面讲述python 导入re模块语法及规则. 1,re模块语法 re.match 从头开始匹配 re.search 匹配 ...
- Dynamic Mapping和常见字段类型
原文:Dynamic Mapping和常见字段类型 版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn. ...