答案是$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. RxJava学习入门

    RxJava是什么 一个词:异步. RxJava 在 GitHub 主页上的自我介绍是 "a library for composing asynchronous and event-bas ...

  2. android中一个解决办法

    E  Trace(732): error opening trace file: No such file or directory (2)android api 的版本和模拟器的版本不一致导致的

  3. Linux性能分析工具的安装和使用

    转自:http://blog.chinaunix.net/uid-26488891-id-3118279.html Normal 0 7.8 磅 0 2 false false false EN-US ...

  4. Delphi面向对象编程

    一.面向对象介绍 OOP是使用独立的对象(包含数据和代码)作为应用程序模块的范例.虽然OOP不能使得代码容易编写,但是它能够使得代码易于维护.将数据和代码结合在一起,能够使定位和修复错误的工作简单化, ...

  5. 攻城狮在路上(叁)Linux(二十六)--- linux文件系统的特殊查看与操作

    一.boot sector 与 super block的关系: 1.boot sector用于存放引导装载程序,占用1024个字节. 2.super block的大小也为1024字节. 3.若bloc ...

  6. go sample - hello world

    入门级别的hello world package mainimport "fmt"func main() { fmt.Println("blibliblbibl!&quo ...

  7. Angular JS [Draft]

    AngularJS应用是完全运行在客户端的应用.没有后端的支持,我们只能展示随页面一起加载进来的数据.AngularJS提供了几种方式从服务器端获取数据. $http服务 $http 封装了浏览器原生 ...

  8. PHP判断当前访问的是 微信、iphone、android 浏览器

    <?phpvar ua = navigator.userAgent.toLowerCase(); if (ua.match(/MicroMessenger/i)=="micromess ...

  9. thinkphp调用phpqrcode.php生成二维码

    thinkphp3. 把phpqrcode文件夹放在ThinkPHP\Library\Vendor\下面 phpqrcode下载: http://files.cnblogs.com/files/qho ...

  10. hdu 4028 2011上海赛区网络赛H dp+map离散

    一开始用搜索直接超时,看题解会的 #include<iostream> #include<cstdio> #include<map> #include<cst ...