答案是$O(\log n)$级别的,故答案不超过6。

当答案是12345时,暴力枚举+压位检验即可,否则直接输出6。

时间复杂度$O(n^5)$。

#include<cstdio>
#define N 80
#define rep(i,n) for(int i=0;i<n;i++)
typedef unsigned int U;
int n,T;char s[N];
struct P{
U x,y,z;
P(){x=y=z=0;}
P(U _x,U _y,U _z){x=_x,y=_y,z=_z;}
inline P operator|(const P&b){return P(x|b.x,y|b.y,z|b.z);}
inline void set(int p){
if(p<32){x|=1U<<p;return;}
p-=32;
if(p<32){y|=1U<<p;return;}
z|=1U<<(p-32);
}
inline int cnt(){return __builtin_popcount(x)+__builtin_popcount(y)+__builtin_popcount(z);}
}g[N],S;
inline bool one(){
rep(i,n)if(g[i].cnt()==n)return 1;
return 0;
}
inline bool two(){
rep(i,n)rep(j,i)if((g[i]|g[j]).cnt()==n)return 1;
return 0;
}
inline bool three(){
rep(i,n)rep(j,i)rep(k,j)if((g[i]|g[j]|g[k]).cnt()==n)return 1;
return 0;
}
inline bool four(){
rep(i,n)rep(j,i)rep(k,j)rep(l,k)if((g[i]|g[j]|g[k]|g[l]).cnt()==n)return 1;
return 0;
}
inline bool five(){
rep(i,n)rep(j,i)rep(k,j)rep(l,k)rep(m,l)if((g[i]|g[j]|g[k]|g[l]|g[m]).cnt()==n)return 1;
return 0;
}
int main(){
while(~scanf("%d",&n)){
printf("Case %d: ",++T);
rep(i,n){
scanf("%s",s);
g[i]=P();
g[i].set(i);
rep(j,n)if(s[j]=='1')g[i].set(j);
}
if(one()){puts("1");continue;}
if(two()){puts("2");continue;}
if(three()){puts("3");continue;}
if(four()){puts("4");continue;}
if(five()){puts("5");continue;}
puts("6");
}
return 0;
}

  

BZOJ3979 : [WF2012]infiltration的更多相关文章

  1. [WF2012]infiltration

    [WF2012]infiltration 完全图 最多选择logn个点(下取整)(每选择一个点覆盖至少一半的规模) 暴力O(75^5)(不严格)枚举+bitset (随机化也可过) #include& ...

  2. bzoj 3979: [WF2012]infiltration【瞎搞+随机化】

    参考:https://www.cnblogs.com/ccz181078/p/5622200.html 非常服气.jpg 就是random_shuffle几次然后顺着找,ans取min... #inc ...

  3. bzoj AC倒序

    Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...

  4. bzoj 3978: [WF2012]Fibonacci Words

    Description 斐波那契01字符串的定义如下 F(n) = { 0  if n = 0 1  if n = 1 F(n-1)+F(n-2) if n >= 2 } 这里+的定义是字符串的 ...

  5. [WorldFinal 2012E]Infiltration(dfs+图论)

    Description 题意:给定一个点数为n的竞赛图,求图的最小支配集 n<=75 Solution 如果将竞赛图的一个点删去,这个图还是竞赛图 而竞赛图每个点相连的边数为(n-1),那么删去 ...

  6. Constructing continuous functions

    This post summarises different ways of constructing continuous functions, which are introduced in Se ...

  7. 做数据挖掘,就算发 20 几分的 CNS 子刊,也是垃圾!?--转载

    关于数据挖掘发表文章,我们知道很多人是看不上.瞧不起.嗤之以鼻的.大抵是因为这些人平时只发 CNS 主刊,所以才认为通过数据挖掘这种用「别人的数据」或者叫「干实验」来发文章是“「垃圾」,没有什么价值. ...

  8. Can peel peel solve pesticide problem

    Can peel peel solve pesticide problem? Middle peasants medicinal modern agriculture more and more, t ...

  9. Cryptographic method and system

    The present invention relates to the field of security of electronic data and/or communications. In ...

随机推荐

  1. DB2 嵌入式应用中定义游标(开放平台上)

    DECLARE CURSOR statement The DECLARE CURSOR statement defines a cursor. Invocation Although an inter ...

  2. php JS和JQ

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  3. AIX 配置网卡

    ifconfig en0 10.1.1.100 netmask 255.255.255.0 alias

  4. 【jquery】幻灯片效果

    闲着无聊,用Jquery写了一个幻灯片效果. 我这人喜欢造轮子,除了jquery这种有强大开发团队的框架级别JS,其实的一些小程序都是尽量自己写. 一是因为怕出问题了没人问,二是自己写的改起来也方便. ...

  5. 在ubuntu上搭建开发环境4---ubuntu简单的搭建LAMP环境和配置

    最近重新安装了Ubuntu,但是之前的LAMP环境自然也就没有了,实在是不想再去编译搭建LAMP环境(这种方法实在是太费时间,而且太容易遇到各种不知道为什么的错误),所以,就去查查有没有什么简单的搭建 ...

  6. Pyqt QSplashScreen启动画面

    多大数应用程序启动时都会在程序完全启动时显示一个启动画面,在程序完全启动后消失.程序启动画面可以显示一些有关产品的信息,让用户在等待程序启动的同时了解有关产品的功能,也是一个宣传的方式.QSplash ...

  7. 关于Python 获取windows信息收集

    收集一些Python操作windows的代码 (不管是自带的or第三方库)均来自网上 1.shutdown 操作 定时关机.重启.注销 #!/usr/bin/python #-*-coding:utf ...

  8. c++ 左值右值 函数模板

    1.先看一段代码,这就是一种函数模板的用法,但是红色的部分如果把a写成a++或者写成一个常量比如1,都是编译不过的,因为如果是a++的话,实际上首先是取得a的 值0,而0作为一个常量没有地址.写成1也 ...

  9. [v9] 列表页 调用 正文内容 或 自定义 字段(moreinfo的调用方法)

    "才能使用的字段) id content readpoint groupids_view paginationtype maxcharperpage template paytype all ...

  10. 应用程序调试工具gdb,王明学learn

    应用程序调试工具gdb学习使用 一.GDB简介 GDB 是 GNU 发布的一款功能强大的程序调试工具.GDB 主要完成下面三个方面的功能: 1.启动被调试程序. 2.让被调试的程序在指定的位置停住. ...