题目链接

 #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 maxn = ;
int n, m;
int dp[(<<)+];
int ok[maxn][maxn]; void solve(){
dp[] = ;
for(int i = ;i <= n;i++){
for(int j = (<<m);j >= ;j--){
if(dp[j]){ //j状态有i-1头牛
for(int k = ;k <= m;k++){ //每一个牛棚
if(ok[i][k] && (j != (j|(<<(k-)))))
dp[j|(<<(k-))] += dp[j];
}
}
dp[j] = ;
}
}
int ans = ;
for(int i = ;i < (<<m);i++){
ans += dp[i];
}
printf("%d\n", ans);
return;
} int main(){
while(~scanf("%d%d", &n ,&m)){
memset(ok, , sizeof(ok));
memset(dp, , sizeof(dp)); for(int i = ;i <= n;i++){
int a, b;
a = read();
while(a--){
b = read();
ok[i][b] = ;
}
}
solve();
}
return ;
}

Arrange the Bulls的更多相关文章

  1. poj 2441 Arrange the Bulls(状态压缩dp)

    Description Farmer Johnson's Bulls love playing basketball very much. But none of them would like to ...

  2. POJ 2441 Arrange the Bulls 状压dp

    题目链接: http://poj.org/problem?id=2441 Arrange the Bulls Time Limit: 4000MSMemory Limit: 65536K 问题描述 F ...

  3. poj 2441 Arrange the Bulls

    Arrange the Bulls Time Limit: 4000MS   Memory Limit: 65536K Total Submissions: 5427   Accepted: 2069 ...

  4. POJ2441 Arrange the Bulls(状压DP)

    题目是,有n头牛,每头牛都喜爱某几个草地,要把这n头牛分配给m个不同的它们喜爱的草地,问有几种分配方式. dp[n][S]表示前n头牛分配完毕后占用的草地集合是S的方案数 dp[0][0]=1 dp[ ...

  5. Arrange the Bulls [POJ2441] [状压DP]

    题意 n头牛,m个房间,每头牛有自己喜欢的房间,问每头牛都住进自己喜欢的房间有多少种分配方法? Input In the first line of input contains two intege ...

  6. POJ 2441 Arrange the Bulls 状态压缩递推简单题 (状态压缩DP)

    推荐网址,下面是别人的解题报告: http://www.cnblogs.com/chasetheexcellence/archive/2012/04/16/poj2441.html 里面有状态压缩论文 ...

  7. POJ 2441 Arrange the Bulls(状态压缩DP)

    题意很简单,n头牛,m个位置,每头牛有各自喜欢的位置,问安排这n头牛使得每头牛都在各自喜欢的位置有几种安排方法. 2000MS代码: #include <cstdio> #include ...

  8. POJ 2441 Arrange the Bulls(状压DP)

    [题目链接] http://poj.org/problem?id=2441 [题目大意] 每个人有过个喜欢的篮球场地,但是一个场地只能给一个人, 问所有人都有自己喜欢的场地的方案数. [题解] 状态S ...

  9. poj2441 Arrange the Bulls

    思路: 状态压缩dp.需要一点优化,否则容易超时. 实现: #include <cstdio> #include <vector> #include <cstring&g ...

随机推荐

  1. uboot移植添加nfs支持

    手头6410开发板uboot(基于2011.06)其他功能包括ping和tftp都执行正常,唯独缺少nfs. 只需要在其配置文件(每个开发板文件通常名称不同,include/configs/*6410 ...

  2. react-native 支持 gif 图片

    只需要在android/app/build.gradle中的dependencies字段中添加: compile 'com.facebook.fresco:animated-gif:0.13.0' 然 ...

  3. PYTHON 爬虫笔记六:PyQuery库基础用法

    知识点一:PyQuery库详解及其基本使用 初始化 字符串初始化 html = ''' <div> <ul> <li class="item-0"&g ...

  4. 农业公司flash动画模板

    农业公司flash动画素材下载模板是一款绿色水果蔬菜种植企业的flash动画模板. 下载:http://www.huiyi8.com/sc/10576.html

  5. BZOJ 1198 [HNOI2006]军机调度:dfs

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1198 题意: 有n个雇佣军,m个任务. 第i个雇佣军能够参加cnt个任务,分别为temp[ ...

  6. linux命令学习笔记-md5sum 命令详解

    前言 在网络传输.设备之间转存.复制大文件等时,可能会出现传输前后数据不一致的情况.这种情况在网络这种相对更 不稳定的环境中,容易出现.那么校验文件的完整性,也是势在必行的. 使用说明 md5sum命 ...

  7. 使用google浏览器模拟手机终端的方法

    谷歌Chrome浏览器,可以很方便地用来当移动终端模拟器.在Windows的[开始]-->[运行]中输入以下命令,启动谷歌浏览器,即可模拟相应手机的浏览器去访问3G手机网页,前提:将先前开启的谷 ...

  8. 手工创建ASM Disk Groups、为 ASM Disk Groups 添加 disk

    Groups 添加 disk 创建语法说明: 必选参数: (1) 指定disk group 的唯一名称 (不分区大小写) (2) 指定disk group 的冗余级别对于ASM 的镜像冗余,可以指定3 ...

  9. zk 05之:ZooKeeper的配置

    ZooKeeper 的功能特性通过 ZooKeeper 配置文件来进行控制管理( zoo.cfg 配置文件). ZooKeeper 这样的设计其实是有它自身的原因的.通过前面对 ZooKeeper 的 ...

  10. DAL 层引用 System.Net.Http ,引发的一阵心慌

    快下班的时候 代码data 数据层编译失败,引起整个解决方案全部失败:其他同事虽然vs 版本不同,但是都能编译通过:考虑到今天更改过vs 的设置,把今天更改的设置全部都恢复,结果还是不行.最后直接恢复 ...