[WF2012]infiltration

完全图

最多选择logn个点(下取整)(每选择一个点覆盖至少一半的规模)

暴力O(75^5)(不严格)枚举+bitset

(随机化也可过)

#include<bits/stdc++.h>
#define reg register int
#define il inline
#define int long long
#define numb (ch^'0')
using namespace std;
typedef long long ll;
il void rd(ll &x){
char ch;x=;bool fl=false;
while(!isdigit(ch=getchar()))(ch=='-')&&(fl=true);
for(x=numb;isdigit(ch=getchar());x=x*+numb);
(fl==true)&&(x=-x);
}
namespace Miracle{
const int N=;
int n;
char con[N][N];
bitset<N>to[N],now;
bool c1(){
for(reg a1=;a1<=n;++a1)
if(to[a1].count()==n) return true;
return false;
}
bool c2(){
for(reg a1=;a1<=n;++a1)
for(reg a2=a1+;a2<=n;++a2)
if((to[a1]|to[a2]).count()==n) return true;
return false;
}
bool c3(){
for(reg a1=;a1<=n;++a1)
for(reg a2=a1+;a2<=n;++a2)
for(reg a3=a2+;a3<=n;++a3)
if((to[a1]|to[a2]|to[a3]).count()==n) return true;
return false;
}
bool c4(){
for(reg a1=;a1<=n;++a1)
for(reg a2=a1+;a2<=n;++a2)
for(reg a3=a2+;a3<=n;++a3)
for(reg a4=a3+;a4<=n;++a4)
if((to[a1]|to[a2]|to[a3]|to[a4]).count()==n) return true;
return false;
}
bool c5(){
for(reg a1=;a1<=n;++a1)
for(reg a2=a1+;a2<=n;++a2)
for(reg a3=a2+;a3<=n;++a3)
for(reg a4=a3+;a4<=n;++a4)
for(reg a5=a4+;a5<=n;++a5)
if((to[a1]|to[a2]|to[a3]|to[a4]|to[a5]).count()==n) return true;
return false;
}
int main(){
int o=;
while(scanf("%d",&n)!=EOF){
for(reg i=;i<=n;++i) to[i].reset();
for(reg i=;i<=n;++i){
scanf("%s",con[i]+);
for(reg j=;j<=n;++j){
if(i==j) continue;
if(con[i][j]=='')to[i][j]=;
else to[i][j]=;
}
to[i][i]=;
}
int ans=;
if(c1()) ans=;
else if(c2()) ans=;
else if(c3()) ans=;
else if(c4()) ans=;
else if(c5()) ans=;
else ans=;
printf("Case %d: %d\n",++o,ans);
}
return ;
} }
signed main(){
Miracle::main();
return ;
} /*
Author: *Miracle*
Date: 2019/2/26 18:48:55
*/

[WF2012]infiltration的更多相关文章

  1. BZOJ3979 : [WF2012]infiltration

    答案是$O(\log n)$级别的,故答案不超过6. 当答案是12345时,暴力枚举+压位检验即可,否则直接输出6. 时间复杂度$O(n^5)$. #include<cstdio> #de ...

  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. c#基础系列2---深入理解 String

    "大菜":源于自己刚踏入猿途混沌时起,自我感觉不是一般的菜,因而得名"大菜",于自身共勉. 扩展阅读:深入理解值类型和引用类型 基本概念 string(严格来说 ...

  2. bash处理一条命令的步骤

    Shell执行一条命令步骤 参考链接: <Learning the bash Shell, 3rd Edition  -- 7.3. Command-Line Processing> &l ...

  3. Notes of Daily Scrum Meeting(12.24)

    平安夜了,我们还在这里辛苦地赶代码,整个人都不好了... 今天的团队任务总结如下: 团队成员 今日团队工作 陈少杰 寻找大神帮助,调试网络连接 王迪 建立搜索的UI界面,把算法加入进去 金鑫 调试网络 ...

  4. slot 插槽的作用域用法(摘自vue.js 官网)

    有的时候你希望提供的组件带有一个可从子组件获取数据的可复用的插槽.例如一个简单的 <todo-list> 组件的模板可能包含了如下代码: <ul> <li v-for=& ...

  5. opencv学习笔记(五)

    线性滤波 方框滤波--boxblur函数 均值滤波(邻域平均滤波)--blur函数 高斯滤波--GaussianBlur函数 中值滤波--medianBlur函数 双边滤波--bilateralFil ...

  6. 设备 VMnet0 上的网桥当前未运行。此虚拟机无法与主机或网络中的其他计算机通信。

    http://www.cnblogs.com/baihuitestsoftware/articles/4223552.html 因为试用Windows10教育版下的Docker打开过Hyper-V,虽 ...

  7. HTML 5 placeHolder

    <html> <body> <input type="text" id="idNum" placeholder="pla ...

  8. [转帖]ARM 相关内容

    ARM内核全解析,从ARM7,ARM9到Cortex-A7,A8,A9,A12,A15到Cortex-A53,A57 http://www.myir-tech.com/resource/448.asp ...

  9. sql优化问题笔记(mysql)

    相信大家平时面试都会遇到这个问题:平时你都是怎么对sql进行调优的? 此篇文章相当于一个随便笔记,根据朋友们的聊天记录整理而成,如有不对,请指正! 注意:这篇是以mysql整理的 查看sql计划分析 ...

  10. 创建一个规范的django项目

    1. 创建项目 2. 创建static目录及配置 1.创建放css, javascript,img的目录 2.在settings.py中将static绝对路径保存到变量STATICFILES_DIRS ...