题目链接

 #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. debian7 amd64版本添加对x86包的支持

    dpkg --add-architecture i386apt-get updateapt-get install ia32-libs ia32-libs-gtk

  2. 《C prime plus (第五版)》 ---第11章 字符串和字符串函数---3

    字符串函数总结: 下面是头文件 string.h 中定义的函数: 序号 函数 & 描述 1 void *memchr(const void *str, int c, size_t n)在参数  ...

  3. MVC+Ext.net零基础学习记录(二)

    很多人在开发一个新的项目时,需要先决定项目的整体架构,是决定使用MVC的同时也不例外,具体包含:项目的多语言性,项目的多风格选择,项目的可扩展性 其中项目的多语言性:http://www.cnblog ...

  4. c# XML-Object对象 序列化-反序列化

    using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Tex ...

  5. 在IIS中某一个网站启用net.tcp

    绑定 高级设置  http和net.tcp用逗号分隔 //擦擦擦,见鬼了,下面的是tcp.net导致我找了好久,都找不出这个错误 //一定要注意,不要写错了. 否则会收到提示:找不到具有绑定 NetT ...

  6. vs2010 windows service 项目不能引用类库项目

    在一个windows 服务项目A中,引用了另外一个项目B,可以使用自动完成,引用其他项目中的类,按理,可以自动提示了,应该就是没问题了,但编译时却提示"未能找到类型或命名空间名称" ...

  7. firfox 和 chrome 移动端Web开发页面调试

    Firefox浏览: 1."Alt+t" 选择工具栏中的“工具”>Web开发者工具>查看器>点击红框所指的地方 或者 F12 [当然这个歌前提是你没有安装fire ...

  8. Posix线程编程指南(3)

    这是一个关于Posix线程编程的专栏.作者在阐明概念的基础上,将向您详细讲述Posix线程库API.本文是第三篇将向您讲述线程同步. 一.互斥锁尽管在Posix Thread中同样可以使用IPC的信号 ...

  9. 【Lintcode】113.Remove Duplicates from Sorted List II

    题目: Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct  ...

  10. windows平台下新网络库RIO ( Winsock high-speed networking Registered I/O)

    What's New for Windows Sockets Microsoft Windows 8 and Windows Server 2012 introduce new Windows Soc ...