[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. WinForm 简易仿360界面控件

    因为经常要做一些1.2千行的小工具,WinForm自带的TabCtrl又不美观,所以想做成360的样子,在网上找来找去,都只有散乱的代码,没有可以通用的结构,于是自己写了一个简易的通用控件. 控件主要 ...

  2. 开发CMDB系统

    背景: 在现网环境中服务器多了每天服务器的配置 情况我们很难记住,当某台服务器硬件配置变化后可以第一时间了解,某台服务器出现问题时可以快速定位机架位置,之前都是excel文档,要查某项数据时极不方便. ...

  3. linux-shell-命令总结

    第一种方法执行: 第二种方法执行: 第三种方法执行: 第四种方法:执行 第三种和第四种方法都是在新的进程里执行程序   函数方法 方法就是一个命令,命令写在字符串的第一个位置 type:可以接外部命令 ...

  4. 20135327郭皓--Linux内核分析第八周 进程的切换和系统的一般执行过程

    第八周 进程的切换和系统的一般执行过程 一.进程切换的关键代码switch_to分析 1.进程调度与进程调度的时机分析 不同类型的进程有不同的调度需求 第一种分类: I/O-bound:频繁进行I/O ...

  5. 『编程题全队』Scrum 冲刺博客

    1.介绍小组新加入的成员,Ta担任的角色 Answer: 我们小组的倪兢飞同学决定跳槽到团队あ,我们小组开了一个简短而又严肃的会议,满足倪兢飞同学的意愿,并感谢他为团队做出的巨大贡献.虽然我们遗失了一 ...

  6. Linux curl 一例

    root@PC-RENGUOQIANG:~# curl http://kermit:kermit@192.168.66.182:8080/activiti-rest/service/repositor ...

  7. SQLSERVER 2014 SP1 的服务器 日志文件无法收缩的处理

    1. 公司一台服务器 日子会文件到了 100g+ 但是无法收缩 2. 根据同事的经验进行验证 dbcc loginfo 单独看改数据库的 dbcc loginfo("CWBASEGS60&q ...

  8. 解决vmware与主机无法连通的问题

    我们选择NAT方式,来实现Ubuntu的静态IP地址配置. 打开VMware,在顶部依次选择:编辑 > 虚拟网路编辑器,打开虚拟网路编辑器:去掉VMnet0和VMnet1,只保留VMnet8.然 ...

  9. 关于virtualenv python环境引用 pycharm相关配置的使用讨论

    今天总算决定来搞一波以前从来没有弄清楚的环境问题,也觉得是时候弄明白了. 这里先说关于python的环境引用,再谈到virtualenv最后再谈论我使用的pycharm5.0关于是用python环境的 ...

  10. string.PadLeft & string.PadRight

    比如我想让他的长度是20个字符有很多字符串如string a = "123",只有3个字符怎么让他们在打印或显示在textBox上的时候不够的长度用空格补齐呢? string.Pa ...