[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的更多相关文章
- BZOJ3979 : [WF2012]infiltration
答案是$O(\log n)$级别的,故答案不超过6. 当答案是12345时,暴力枚举+压位检验即可,否则直接输出6. 时间复杂度$O(n^5)$. #include<cstdio> #de ...
- bzoj 3979: [WF2012]infiltration【瞎搞+随机化】
参考:https://www.cnblogs.com/ccz181078/p/5622200.html 非常服气.jpg 就是random_shuffle几次然后顺着找,ans取min... #inc ...
- bzoj AC倒序
Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...
- 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 } 这里+的定义是字符串的 ...
- [WorldFinal 2012E]Infiltration(dfs+图论)
Description 题意:给定一个点数为n的竞赛图,求图的最小支配集 n<=75 Solution 如果将竞赛图的一个点删去,这个图还是竞赛图 而竞赛图每个点相连的边数为(n-1),那么删去 ...
- Constructing continuous functions
This post summarises different ways of constructing continuous functions, which are introduced in Se ...
- 做数据挖掘,就算发 20 几分的 CNS 子刊,也是垃圾!?--转载
关于数据挖掘发表文章,我们知道很多人是看不上.瞧不起.嗤之以鼻的.大抵是因为这些人平时只发 CNS 主刊,所以才认为通过数据挖掘这种用「别人的数据」或者叫「干实验」来发文章是“「垃圾」,没有什么价值. ...
- Can peel peel solve pesticide problem
Can peel peel solve pesticide problem? Middle peasants medicinal modern agriculture more and more, t ...
- Cryptographic method and system
The present invention relates to the field of security of electronic data and/or communications. In ...
随机推荐
- 基于HTML5 Canvas 实现地铁站监控
伴随国内经济的高速发展,人们对安全的要求越来越高.为了防止下列情况的发生,您需要考虑安装安防系统: 提供证据与线索:很多工厂银行发生偷盗或者事故相关机关可以根据录像信息侦破案件,这个是非常重要的一个线 ...
- 第六次Scrum meeting
第六次Scrum meeting 任务及完成度: 成员 12.21 12.22 陈谋 任务1040:完成stackoverflow的数据处理后的json处理(98%) 任务1114-1:完成对网页数 ...
- Scrum Meeting 8
第八次会议 No_00:工作情况 No_01:任务说明 待完成 已完成 No_10:燃尽图 No_11:照片记录 待更新 No_100:代码/文档签入记录 No_101:出席表 ...
- 一些调格式的经验 & 插入图注和尾注
一些调格式的经验(以Word2010为例) 1. 从目录正文分别编页码 将光标放在要重新编写页码起始页的最开始位置 分节:页面布局->分隔符->分节符(连续) 插入页码后,选中页码起始页页 ...
- myeclipse从SVN检出项目报错
今天是在公司实习的第一天,从SVN服务器检出项目后发现报错. 解决方法: 1. 右键项目,选择属性properties-->选择resource-->将others选中并换为UTF-8 2 ...
- A11-java学习-二维数组-面向对象概念-类的编写-测试类的编写-创建对象-使用对象-递归
二维数组的内存结构和使用 引用类型的内存结构 栈区.堆区.方法区.数据栈等内存分析和介绍 面向对象.面向过程区别和发展 类型的定义 引用类型.值类型 预定义类型和自定义类型 类型与对象(实例) 对象的 ...
- JS 柯里化 (curry)
用 JS 理解柯里化 函数式编程风格,试图以函数作为参数传递(回调)和无副作用的返回函数(修改程序的状态). 很多语言采用了这种编程风格.JavaScript,Haskell,Clojure,Erla ...
- 2017[BUAA软工]第0次个人作业
第一部分:结缘计算机 1.你为什么选择计算机专业?你认为你的条件如何?和这些博主比呢? ●其实填写志愿之前并不知道要学什么专业,当初选择计算机是因为计算机就业前景好.方向多.计算机应用的领域无处不在, ...
- JMX configuration for Tomcat
Window下执行步骤: D:\apache-tomcat-7.0.57\bin\catalina.bat set CATALINA_OPTS=-Dcom.sun.management.jmxremo ...
- oracle 18c centos7 设置开机自动启动Oracle
学习自: http://blog.csdn.net/condywl/article/details/57129696 1. 在root用户下进行修改 配置文件 /etc/oratab vim /etc ...