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]消毒的更多相关文章

  1. bzoj千题计划300:bzoj4823: [Cqoi2017]老C的方块

    http://www.lydsy.com/JudgeOnline/problem.php?id=4823 讨厌的形状就是四联通图 且左右各连一个方块 那么破坏所有满足条件的四联通就好了 按上图方式染色 ...

  2. bzoj千题计划142:bzoj3144: [Hnoi2013]切糕

    http://www.lydsy.com/JudgeOnline/problem.php?id=3144 如果D=2 ,两个点,高度为4,建图如下 #include<queue> #inc ...

  3. bzoj千题计划294:bzoj3139: [Hnoi2013]比赛

    http://www.lydsy.com/JudgeOnline/problem.php?id=3139 队伍的顺序不会影响结果 将队伍的得分情况作为状态,记忆化搜索 就是先搜索第一只队伍的得分情况, ...

  4. bzoj千题计划293:bzoj3142: [Hnoi2013]数列

    http://www.lydsy.com/JudgeOnline/problem.php?id=3142 如果已知数列的差分数列a[1]~a[k-1] 那么这种差分方式对答案的贡献为 N-Σ a[i] ...

  5. bzoj千题计划290:bzoj3143: [Hnoi2013]游走

    http://www.lydsy.com/JudgeOnline/problem.php?id=3143 计算每条边经过的概率e[] 然后经过概率多的分配的编号大,经过概率少的分配的编号小 如何计算边 ...

  6. bzoj千题计划196:bzoj4826: [Hnoi2017]影魔

    http://www.lydsy.com/JudgeOnline/problem.php?id=4826 吐槽一下bzoj这道题的排版是真丑... 我还是粘洛谷的题面吧... 提供p1的攻击力:i,j ...

  7. bzoj千题计划280:bzoj4592: [Shoi2015]脑洞治疗仪

    http://www.lydsy.com/JudgeOnline/problem.php?id=4592 注意操作1 先挖再补,就是补的范围可以包含挖的范围 SHOI2015 的题 略水啊(逃) #i ...

  8. bzoj千题计划177:bzoj1858: [Scoi2010]序列操作

    http://www.lydsy.com/JudgeOnline/problem.php?id=1858 2018 自己写的第1题,一遍过 ^_^ 元旦快乐 #include<cstdio> ...

  9. bzoj千题计划317:bzoj4650: [Noi2016]优秀的拆分(后缀数组+差分)

    https://www.lydsy.com/JudgeOnline/problem.php?id=4650 如果能够预处理出 suf[i] 以i结尾的形式为AA的子串个数 pre[i] 以i开头的形式 ...

随机推荐

  1. 简单测评拨号VPS——云立方&淘宝卖家

    做爬虫的同学不可避免地要使用代理IP,除了各网站公布的免费代理IP外,我们还可以选择拨号VPS,本文简单对两家(类)拨号VPS提供商进行测评,如有差错,欢迎指出,非常感谢. 使用过程 云立方 第一次听 ...

  2. 小白之selenium+python关于cookies绕开登录2

    首先,由于新开始在博客园中写随笔,可能在内容的布局方面就不太懂,导致布局很丑,各位见谅,但是字还是原来的那字,内容还是原来的内容,少了点包装, 下面是对cookie的扩展知识 1.配置文件存储在哪里? ...

  3. 记录Jenkins+gitlab+maven

    摘要 昨天抽空将jenkins+gitlab(git)+maven整合了一下,再次记录一下以防下次再去查找省的麻烦. git.maven.java配置 启动jenkins之后进入系统管理里面的Glob ...

  4. 3Sum(or k_Sum)

    Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find ...

  5. Kafka高性能吞吐关键技术分析

    Apache Kafka官网提供的性能说明: Benchmarking Apache Kafka: 2 Million Writes Per Second (On Three Cheap Machin ...

  6. HAOI2017 新型城市化 二分图的最大独立集+最大流+强连通缩点

    题目链接(洛谷):https://www.luogu.org/problemnew/show/P3731 题意概述:给出一张二分图,询问删掉哪些边之后可以使这张二分图的最大独立集变大.N<=10 ...

  7. redis启动停止+密码认证

    redis启动停止命令 ./bin/redis-server redis.conf ./bin/redis-cli -h 127.0.0.1 -p 6379 shutdown flushall ——& ...

  8. 冲刺Two之站立会议1

    今天我们开始了第二个冲刺期的工作,大家重新讨论了下个阶段的工作内容,由于上次演示我们主要只是实现了摄像头开启.通信和语音通话的功能,而且各部分还有待完善.所以我们决定了之后的主要工作的内容:之前服务器 ...

  9. Daily Scrum - 11/13

    时间:3:00pm - 3:30pm 今天小组例会主要是任烁分享他对WP源码的code review,通过分析与讨论我们了解了背单词模块的主要类(主要是词和单词本),取词方式(调用数据库接口),算法( ...

  10. Daily Scrum 10.22

    (写于10.22周四0晨) 昨天任务还未完成的继续完成任务. 每个人都查看自己的TFS,修改已经完成的任务状态,改为已关闭-已完成. 由于android studio运行过于慢,我们统一采取eclip ...