[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 ...
随机推荐
- [UWP 自定义控件]了解模板化控件(7):支持Command
以我的经验来说,要让TemplatedControl支持Command的需求不会很多,大部分情况用附加属性解决这个需求会更便利些,譬如UWPCommunityToolkit的HyperlinkExte ...
- 《DISTRIBUTED SYSTEMS Concepts and Design》读书笔记 一
第二章 系统模型 描述分布式系统的三种模型 Physical models : 用机器,网络,硬件等语言去描述整个系统. Architectural models : 用计算.计算任务.计算单元等语言 ...
- J-query extend()方法
1.如果没有冲突参数会弥在后面. 2.参数如果和前面的参数存在相同的名称,那么后面的会覆盖前面的参数值.
- Python中 and or 运算顺序详解 --- 短路逻辑
核心思想 表达式从左至右运算,若 or 的左侧逻辑值为 True ,则短路 or 后所有的表达式(不管是 and 还是 or),直接输出 or 左侧表达式 . 表达式从左至右运算,若 and 的左侧逻 ...
- 理解Vue 2.5的Diff算法
DOM"天生就慢",所以前端各大框架都提供了对DOM操作进行优化的办法,Angular中的是脏值检查,React首先提出了Virtual Dom,Vue2.0也加入了Virtual ...
- 7-Python3从入门到实战—基础之数据类型(字典-Dictionary)
Python从入门到实战系列--目录 字典的定义 字典是另一种可变容器模型,且可存储任意类型对象:使用键-值(key-value)存储,具有极快的查找速度: 字典的每个键值(key=>value ...
- JSP中properties文件的路径问题
做练习的时候,写了个properties文件,放在src/servlet/目录下,访问文件问题花了点时间折腾,最终得到解决,记下. 环境:eclipse jee oxygen,tomcat 9.0. ...
- BUAA软工个人作业Week3-案例分析
一. 调研评测 评测项目:为了联系移动和PC版,我同时下载了必应词典的Android版本和UWP版本,选择UWP的原因是想看看微软推广的UWP在微软自己的应用上的效果.当然主要是对安卓的测评(UWP用 ...
- cmd 安装mysql
838444958 http://www.runoob.com/mysql/mysql-install.html (cmd)Aa410766383 mysql password bin目录下 ...
- css CSS常见布局解决方案
CSS常见布局解决方案说起css布局,那么一定得聊聊盒模型,清除浮动,position,display什么的,但本篇本不是讲这些基础知识的,而是给出各种布局的解决方案.水平居中布局首先我们来看看水平居 ...