Easy Finding poj-3470

    题目大意:给你一个01矩阵,问能否选出一些行,使得这些行所新组成的01矩阵每列中有且只有1个1。

    注释:1<=行数<=16,1<=列数<=300.

      想法:对于一个单独的01矩阵来讲,我们可以用一个数表示其中的每一行,然后暴力枚举每一行选取情况即可。

    最后,附上丑陋的代码... ...

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int c[320];
bool flag;
int main()
{
int n,m;
while(~scanf("%d%d",&n,&m))
{
memset(c,0,sizeof(c));
flag=0;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
int a;
scanf("%d",&a);
c[j]+=(a<<(i-1));
}
}
for(int s=0;s<(1<<n);s++)
{
for(int j=1;j<=m;j++)
{
int middle;
middle=s&c[j];
if(middle!=0 && (middle&(middle-1))==0)
{
if(j==m)
flag=1;
else continue;
}
else break;
}
if(flag)
break;
}
if(flag) printf("Yes, I found it\n");
else printf("It is impossible\n");
}
return 0;
}

    小结:位运算的优先级是滞后的,但是sublime里会吹warning,如果利用优先级的话。

[poj3740]Easy Finding_状态压缩_dfs的更多相关文章

  1. Marriage Ceremonies(状态压缩dp)

     Marriage Ceremonies Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu ...

  2. Number Game_状态压缩

    Description Christine and Matt are playing an exciting game they just invented: the Number Game. The ...

  3. UVALive 3953 Strange Billboard (状态压缩+枚举)

    Strange Billboard 题目链接: http://acm.hust.edu.cn/vjudge/contest/129733#problem/A Description The marke ...

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

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

  5. 【BZOJ2734】【HNOI2012】集合选数(状态压缩,动态规划)

    [BZOJ2734][HNOI2012]集合选数(状态压缩,动态规划) 题面 Description <集合论与图论>这门课程有一道作业题,要求同学们求出{1, 2, 3, 4, 5}的所 ...

  6. hdu 4352 数位dp + 状态压缩

    XHXJ's LIS Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  7. POJ-1143(状态压缩)

    Number Game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3432 Accepted: 1399 Descripti ...

  8. hdu 4352 XHXJ's LIS 数位dp+状态压缩

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4352 XHXJ's LIS Time Limit: 2000/1000 MS (Java/Others ...

  9. hdu 4352 XHXJ's LIS (数位dp+状态压缩)

    Description #define xhxj (Xin Hang senior sister(学姐)) If you do not know xhxj, then carefully readin ...

随机推荐

  1. php替换文件指定行的内容

    //第一种 利用file 函数 读取文件,每一行都是一个数组元素 $arr = file($file); $arr[$line] = "hello"; file_put_conte ...

  2. SSH2三大框架SQL查询

    /** * 查询省份名称 * @author YHD * @return * @see */ @SuppressWarnings("unchecked") @Override pu ...

  3. 错误代码: 1052 Column 'stu_id' in field list is ambiguous

    1.错误描述 1 queries executed, 0 success, 1 errors, 0 warnings 查询:select stu_id, (SELECT stu_name FROM t ...

  4. Invalid property 'url' of bean class [com.mchange.v2.c3p0.ComboPooledDataSource]

    1.错误描述 INFO:2015-05-01 13:13:05[localhost-startStop-1] - Initializing c3p0-0.9.2.1 [built 20-March-2 ...

  5. Java中的List转换成JSON报错(三)

    1.错误描述 Exception in thread "main" java.lang.NoClassDefFoundError: net/sf/ezmorph/Morpher a ...

  6. “net usershare”返回错误 255

    1 错误描述 youhaidong@youhaidong:~$ sudo nautilus (nautilus:4429): Gtk-WARNING **: Failed to register cl ...

  7. IIS易混概念小结

    IIS连接数 常识: 虚拟主机会限制IIS连接数,关于其含义,差不多每个主机供应商都有一套自己的说法,微软也没有给出很明确的解释: 含义: IIS服务器可以同时容纳客户请求的最高连接数,准确的说应该叫 ...

  8. Query 插件为什么要return this.each()

    jQuery.fn.test2= function(){ this.css("background","#ff0");//这里面的this为jquery对象,而 ...

  9. 项目中的导出(jxl插件)

    第一步,获取要导出的参数,为导出做准备 public ModelAndView downloadInfo(final HttpServletRequest request, final HttpSer ...

  10. 一次断电后docker问题的排解

    这篇文章是一次真实的排查经历,可能对大多数人没什么作用,慎看. 断电后来电,服务器启动,手工启动各个docker,大部分正常,小部分还是出错,错误信息: <html> <head&g ...