2019.1.9交流题,现在看还是不会,,,

如果只有一边,那么Hall定理即可。

两边?分别满足Hall定理,就是合法的!

证明(构造方案):

左集合先任意形成一个合法匹配,单点增量加入右集合和与右集合有关的边进行调整

加入bj,枚举连接bj的边,连向ai

直接大力匈牙利匹配即可。由于Hall定理成立,所过之处一定能返回true

DP之后双指针即可。

注意,左、右是空集合也合法

#include<bits/stdc++.h>
#define reg register int
#define il inline
#define fi first
#define se second
#define mk(a,b) make_pair(a,b)
#define numb (ch^'0')
#define pb push_back
#define solid const auto &
#define enter cout<<endl
#define pii pair<int,int>
using namespace std;
typedef long long ll;
template<class T>il void rd(T &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);}
template<class T>il void output(T x){if(x/)output(x/);putchar(x%+'');}
template<class T>il void ot(T x){if(x<) putchar('-'),x=-x;output(x);putchar(' ');}
template<class T>il void prt(T a[],int st,int nd){for(reg i=st;i<=nd;++i) ot(a[i]);putchar('\n');}
namespace Modulo{
const int mod=;
int ad(int x,int y){return (x+y)>=mod?x+y-mod:x+y;}
void inc(int &x,int y){x=ad(x,y);}
int mul(int x,int y){return (ll)x*y%mod;}
void inc2(int &x,int y){x=mul(x,y);}
int qm(int x,int y=mod-){int ret=;while(y){if(y&) ret=mul(x,ret);x=mul(x,x);y>>=;}return ret;}
template<class ...Args>il int ad(const int a,const int b,const Args &...args) {return ad(ad(a,b),args...);}
template<class ...Args>il int mul(const int a,const int b,const Args &...args) {return mul(mul(a,b),args...);}
}
// using namespace Modulo;
namespace Miracle{
const int N=;
int sz[<<N];
int lim;
struct SET{
int n;
int go[N];
int val[N];
int f[<<N];
int s[<<N];
int ok[<<N],cnt;
void in(){
for(reg i=;i<n;++i) rd(val[i]);
}
void dp(){
// cout<<"D-------P "<<endl;
f[]=;
for(reg i=;i<(<<n);++i){
int to=;
for(reg j=;j<n;++j){
if((i>>j)&) {
to|=go[j];
s[i]+=val[j];
}
}
f[i]=(sz[to]>=sz[i]);
if(f[i]){
for(reg j=;j<n;++j){
if((i>>j)&) f[i]&=f[i^(<<j)];
}
}
if(f[i]){
// cout<<" OK "<<i<<" s "<<s[i]<<endl;
ok[++cnt]=s[i];
}
}
sort(ok+,ok+cnt+);
}
}le,ri;
char s[N];
int main(){
rd(le.n);rd(ri.n);
int up=max(le.n,ri.n)+;
for(reg i=;i<le.n;++i){
scanf("%s",s);
for(reg j=;j<ri.n;++j){
if(s[j]=='') le.go[i]|=(<<j),ri.go[j]|=(<<i);
}
}
le.in();ri.in();
rd(lim); for(reg i=;i<(<<up);++i){
sz[i]=sz[i>>]+(i&);
}
le.dp();ri.dp();
// cout<<le.cnt<<" "<<ri.cnt<<endl;
ll ans=;
int ptr=ri.cnt;
for(reg i=;i<=le.cnt;++i){
while(ptr&&le.ok[i]+ri.ok[ptr]>=lim) --ptr;
// ptr=lower_bound(ri.ok+1,ri.ok+ri.cnt+1,lim-le.ok[i])-ri.ok-1;
ans+=ri.cnt-ptr;
}
cout<<ans;
return ;
} }
signed main(){
Miracle::main();
return ;
} /*
Author: *Miracle*
*/

bzoj4788: [CERC2016]Bipartite Blanket的更多相关文章

  1. bzoj 4788: [CERC2016]Bipartite Blanket【hall定理+状压】

    考虑当前合法的一个点集s,如果他合法,那么一定有一个完备匹配的点集包含这个点集,也就是两边都满足hall定理的话这两边拼起来的点集也满足要求 所以分别状压两边点集用hall定理转移判断当前点集是否合法 ...

  2. 【Codeforces】Gym 101173B Bipartite Blanket 霍尔定理+状压DP

    题意 给一张$n\times m$二分图,带点权,问有多少完美匹配子集满足权值和大于等于$t$ 这里有一个结论:对于二分图$\mathbb{A}$和$\mathbb{B}$集合,如果子集$A \in ...

  3. Day5网络流

    算法 无源汇上下界可行流 先强制流过l的流量 从s到每个正权点连流量为l的流量 从每个负权点向t连-l的流量 如果容量为0,则不连边 有源汇上下界最大流 去掉下界 先求出可行流 再求S到T的最大流 有 ...

  4. Note - 千年食谱颂

      其实是兔子收集的各种下饭操作与名菜食谱.( 零·策略篇 多校 NOIP 2021.11.05:   这个真的是,我每次打毛毛虫剖分都是 rush 状态 qwq.像这种 已知代码难度大.不便于调试的 ...

  5. 二分图点染色 BestCoder 1st Anniversary($) 1004 Bipartite Graph

    题目传送门 /* 二分图点染色:这题就是将点分成两个集合就可以了,点染色用dfs做, 剩下的点放到点少的集合里去 官方解答:首先二分图可以分成两类点X和Y, 完全二分图的边数就是|X|*|Y|.我们的 ...

  6. dataStructure@ Check whether a given graph is Bipartite or not

    Check whether a given graph is Bipartite or not A Bipartite Graph is a graph whose vertices can be d ...

  7. hdu 5313 Bipartite Graph(dfs染色 或者 并查集)

    Problem Description Soda has a bipartite graph with n vertices and m undirected edges. Now he wants ...

  8. [LeetCode] Is Graph Bipartite? 是二分图么?

    Given an undirected graph, return true if and only if it is bipartite. Recall that a graph is bipart ...

  9. [Swift]LeetCode785. 判断二分图 | Is Graph Bipartite?

    Given an undirected graph, return true if and only if it is bipartite. Recall that a graph is bipart ...

随机推荐

  1. csp-s模拟100,101T1,T2题解

    题面:https://www.cnblogs.com/Juve/articles/11799325.html 我太蒻了只会T1T2 组合: 欧拉路板子?不会呀... 然后打了个优化,防止暴栈 #inc ...

  2. 计算几何——直线交点poj1269

    求直线交点还是要推一个公式的.. 见博客https://blog.csdn.net/u013050857/article/details/40923789 还要学一下向量的定点比分法 另外poj精度好 ...

  3. duilib教程之duilib入门简明教程8.完整的自绘标题栏

    看了前面那么多教程,相信对duilib已有基本映像了,我们就快马加鞭,做出一个完整的自绘标题栏吧~    看到下面这个效果图,小伙伴们是不是有点惊呆了呢~O(∩_∩)O~      duilib实现以 ...

  4. (转)获取android手机内部存储空间和外部存储空间的参数 && 如何决定一个apk的安装位置

    转:http://blog.csdn.net/zhandoushi1982/article/details/8560233 获取android文件系统的信息,需要Environment类和StatFs ...

  5. 网络安全系列 之 SQL注入学习总结

    目录 1. sql注入概述 2. sql注入测试工具 3. sql注入防御方法 3.1 问题来源 3.2 防御方法 4. SQL注入防御举例 4.1 使用JDBC时,SQL语句进行了拼接 4.2 使用 ...

  6. java编程规约一

    提高开发效率,比较重视代码规范,尤其是可扩展性和可维护性,以及可读性.如果你是一个刚进公司的开发者,最好先问问前辈是否有 内部的开发规范,花点时间过一遍.即使提交代码没有review的步骤,自己心里应 ...

  7. Linux 下 Nand Flash 调用关系

    Nand Flash 设备添加时数据结构包含关系 struct mtd_partition        partition_info[] --> struct s3c2410_nand_set ...

  8. 解决mysql中无法修改事务隔离级别的问题

    使用SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;修改数据库隔离级别, 然后执行SELECT @@TX_ISOLATION;后发现数据库的隔离级别并 ...

  9. UNION操作用于合并两个或多个 SELECT 语句的结果集。

    UNION操作用于合并两个或多个 SELECT 语句的结果集. 大理石平台价格 使用示例: $Model->field('name') ->table('think_user_0') -& ...

  10. Python-函数基础(1)

    目录 函数定义 什么是函数? 定义函数三种形式 函数定义的特性 函数调用 函数返回值 return的特性: 函数的参数 有参函数 形参 位置形参 默认形参 实参 位置实参 关键字实参 可变长参数 形参 ...