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 ...
随机推荐
- VMware 虚拟化编程(8) — 多线程中的 VixDiskLib
目录 目录 前文列表 多线程注意事项 多线程中的 VixDiskLib 前文列表 VMware 虚拟化编程(1) - VMDK/VDDK/VixDiskLib/VADP 概念简析 VMware 虚拟化 ...
- oracle linux 7使用udev绑盘操作
参考:Oracle Linux 7: Udev rule for ASM Cannot Place the ASM Disk in a Directory under /dev (Doc ID 221 ...
- 应用安全 - 软件漏洞 - 泛微OA漏洞汇总
SQL注入 前台SQL注入 用户名:admin' or password like 'c4ca4238a0b923820dcc509a6f75849b' and 'a'='a 密码: 1 验证页面参数 ...
- 001--PowerDesigner连接MySQL
PowerDesigner连接MySQL(一) 博客地址:https://blog.csdn.net/codemonkey_king/article/details/53263597 https:// ...
- Haystack Python全文检索框架
Haystack 1.什么是Haystack Haystack是django的开源全文搜索框架(全文检索不同于特定字段的模糊查询,使用全文检索的效率更高 ),该框架支持Solr,Elasticsear ...
- Flask使用原生sql语句
安装pip install flask-sqlalchemy 创建数据库对象 # 设置数据库连接地址app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://r ...
- type动态创建类
在一些特定场合,需要动态创建类,比如创建表单,就会用到type动态创建类,举个例子: class Person(object): def __init__(self,name,age): self.n ...
- 多线程07-Monitor.TryEnter
); Console.WriteLine())) { Console.WriteLine ...
- c++ const 修饰变量位置含义
c++ const 修饰变量位置含义 const 修饰成员变量 const修饰指针变量时: 只有一个const,如果const位于*左侧,表示指针所指数据是常量,也就是指向常量的指针,不能通过解引用修 ...
- 显式Mapping设置与常见参数介绍
原文:显式Mapping设置与常见参数介绍 版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/ ...