bzoj千题计划295:bzoj3140: [Hnoi2013]消毒
http://www.lydsy.com/JudgeOnline/problem.php?id=3140
如果只有两维,那就是二分图最小点覆盖
现在是三维,但是a*b*c<=5000,说明最小的那一维不会超过17
将最小的那一维作为正方形的高
然后枚举要消哪些层,剩下的层看成一层 做最小点覆盖
注意卡常
#include<cstdio>
#include<cstring>
#include<iostream> using namespace std; #define N 5001 struct node
{
int i,j,k;
}e[N]; bool have[]; int front[N],to[N],nxt[N],tot;7 int match[N];
int tim,vis[N]; void read(int &x)
{
x=; char c=getchar();
while(!isdigit(c)) c=getchar();
while(isdigit(c)) { x=x*+c-''; c=getchar(); }
} bool go(int u)
{
int v;
for(int i=front[u];i;i=nxt[i])
{
v=to[i];
if(vis[v]!=tim)
{
vis[v]=tim;
if(!match[v] || go(match[v]))
{
match[v]=u;
return true;
}
}
}
return false;
} int count(int x)
{
int sum=;
while(x) sum+=x&,x>>=;
return sum;
} void add(int u,int v)
{
to[++tot]=v; nxt[tot]=front[u]; front[u]=tot;
} int main()
{
int T,a,b,c;
int ty,x;
int S,cnt; bool tag;
int ans,now;
read(T);
while(T--)
{
read(a); read(b); read(c);
if(a<=b && a<=c) ty=;
else if(b<=a && b<=c) ty=;
else ty=;
memset(have,false,sizeof(have));
cnt=;
for(int i=;i<=a;++i)
for(int j=;j<=b;++j)
for(int k=;k<=c;++k)
{
read(x);
if(!x) continue;
cnt++;
if(ty==) e[cnt].i=i,e[cnt].j=j,e[cnt].k=k;
if(ty==) e[cnt].i=j,e[cnt].j=i,e[cnt].k=k;
if(ty==) e[cnt].i=k,e[cnt].j=i,e[cnt].k=j;
have[e[cnt].i]=true;
}
if(ty==) swap(a,b);
else if(ty==) swap(b,c),swap(a,b);
ans=a;
S=<<a;
for(int s=;s<S;++s)
{
tag=true;
for(int i=;i<=a && tag;++i)
if(<<i-&s && !have[i]) tag=false;
if(!tag) continue;
now=count(s);
tot=;
memset(front,,sizeof(*front)*(b+));
for(int i=;i<=cnt;++i)
if(!(<<e[i].i-&s)) add(e[i].j,e[i].k);
memset(match,,sizeof(*match)*(c+));
for(int i=;i<=b;++i)
{
tim++;
if(go(i)) now++;
if(now>=ans) break;
}
ans=ans<=now ? ans : now;
}
printf("%d\n",ans);
}
}
bzoj千题计划295:bzoj3140: [Hnoi2013]消毒的更多相关文章
- bzoj千题计划300:bzoj4823: [Cqoi2017]老C的方块
http://www.lydsy.com/JudgeOnline/problem.php?id=4823 讨厌的形状就是四联通图 且左右各连一个方块 那么破坏所有满足条件的四联通就好了 按上图方式染色 ...
- bzoj千题计划142:bzoj3144: [Hnoi2013]切糕
http://www.lydsy.com/JudgeOnline/problem.php?id=3144 如果D=2 ,两个点,高度为4,建图如下 #include<queue> #inc ...
- bzoj千题计划294:bzoj3139: [Hnoi2013]比赛
http://www.lydsy.com/JudgeOnline/problem.php?id=3139 队伍的顺序不会影响结果 将队伍的得分情况作为状态,记忆化搜索 就是先搜索第一只队伍的得分情况, ...
- bzoj千题计划293:bzoj3142: [Hnoi2013]数列
http://www.lydsy.com/JudgeOnline/problem.php?id=3142 如果已知数列的差分数列a[1]~a[k-1] 那么这种差分方式对答案的贡献为 N-Σ a[i] ...
- bzoj千题计划290:bzoj3143: [Hnoi2013]游走
http://www.lydsy.com/JudgeOnline/problem.php?id=3143 计算每条边经过的概率e[] 然后经过概率多的分配的编号大,经过概率少的分配的编号小 如何计算边 ...
- bzoj千题计划196:bzoj4826: [Hnoi2017]影魔
http://www.lydsy.com/JudgeOnline/problem.php?id=4826 吐槽一下bzoj这道题的排版是真丑... 我还是粘洛谷的题面吧... 提供p1的攻击力:i,j ...
- bzoj千题计划280:bzoj4592: [Shoi2015]脑洞治疗仪
http://www.lydsy.com/JudgeOnline/problem.php?id=4592 注意操作1 先挖再补,就是补的范围可以包含挖的范围 SHOI2015 的题 略水啊(逃) #i ...
- bzoj千题计划177:bzoj1858: [Scoi2010]序列操作
http://www.lydsy.com/JudgeOnline/problem.php?id=1858 2018 自己写的第1题,一遍过 ^_^ 元旦快乐 #include<cstdio> ...
- bzoj千题计划317:bzoj4650: [Noi2016]优秀的拆分(后缀数组+差分)
https://www.lydsy.com/JudgeOnline/problem.php?id=4650 如果能够预处理出 suf[i] 以i结尾的形式为AA的子串个数 pre[i] 以i开头的形式 ...
随机推荐
- effective c++ 笔记 (26-29)
//---------------------------15/04/09---------------------------- //#26 尽可能延后变量定义式的出现时间 { /* 1:只要 ...
- java批量爬取电影资源
摘要 网上有很多个人站来分享电影资源,其实有时候我们自己也想做这个一个电影站来分享资源.但是这个时候就有一个问题,电影的资源应该从哪里来呢?难道要自己一条条手动去从网络上获取,这样无疑是缓慢而又效率低 ...
- 第三次Scrum meeting
第三次Scrum meeting 会议主要内容: 测试方面:确定测试的各个环节以及测试的相关要求,完成初步的功能测试.同时在测试时仔细记录相应错误信息,并进行备注. 沟通方面:同Dream团队(学霸前 ...
- Haskell(一 )------ Windos下环境配置
1.去官网下载安装包 2.然后运行安装包路径最好就不要改了. 3.打开命令行输入 cabal user-config init 会出现默认的放置配置文件的地址,然后到那个文件夹下修改config文件. ...
- (Alpha)Let's-Chronos分数分配规则
Requirement: 每个团队开一个讨论会,协商讨论团队贡献分的分配方式.每个团队的团队贡献分为50分/人.每个人分数不能相同,请详细说明分数的分配规则. 为了完成此次的团队贡献分的分配任务,我们 ...
- SDN开源项目以及组织机构
SDN开源项目以及组织机构 以上内容均摘自网络 如有侵权,请转告笔者,立即删除 两大组织 ONF (Open Networking Foundation) Google.Facebook.Micros ...
- 第三周(JAVA编写的 wordcount)
import java.io.*; public class WordCount { public static int words=1; public static int lines=1; pub ...
- Docker(二十三)-Docker使用pipework配置本地网络
需求 在使用Docker的过程中,有时候我们会有将Docker容器配置到和主机同一网段的需求.要实现这个需求,我们只要将Docker容器和主机的网卡桥接起来,再给Docker容器配上IP就可以了. 下 ...
- Js单元测试工具 以及 粗浅的对我的快乐运算进行测试
1. Karma的介绍 Karma是Testacular的新名字,在2012年google开源了Testacular,2013年Testacular改名为Karma.Karma是一个让人感到非常神秘的 ...
- subversion & MacOS & Xcode 10
subversion & MacOS Xcode 10 https://developer.apple.com/search/?q=subversion No SVN any more! ht ...