题面

解析

这题其实也是网络流建图。。

首先,转换下思路,

求第k大的数的最小值,

其实就是求一个最小的值,

使选取的点中能有(n-k+1)个的值比它小。

因此,可以采用二分答案,

每次判断一个值,

将比它小的点加到图中跑最大流,

看流量是否大于(n-k+1)。

那么,怎么连边呢?

其实,我们可以每一行连源点,流量为1,

每一列连汇点,流量为1,

中间源点与汇点连INF。

最后判断就能AC了!

上AC代码:

#include<bits/stdc++.h>
using namespace std; inline int read(){
int sum=,f=;char ch=getchar();
while(ch>'' || ch<''){if(ch=='-')f=-;ch=getchar();}
while(ch>='' && ch<=''){sum=sum*+ch-'';ch=getchar();}
return f*sum;
} const int INF=0x3f3f3f3f;
struct node{
int next,to,v;
}e[];
int n,k,m,ans,s,t;
int a[][];
int maxn=;
int head[],cnt;
int d[],cur[]; void add(int x,int y,int v){
e[++cnt].to=head[x];e[cnt].next=y;
e[cnt].v=v;head[x]=cnt;
e[++cnt].to=head[y];e[cnt].next=x;
e[cnt].v=;head[y]=cnt;
} bool bfs(){
memset(d,,sizeof(d));
memcpy(cur,head,sizeof(cur));
queue <int> que;
que.push(s);
d[s]=;
while(!que.empty()){
int x=que.front();
que.pop();
for(int i=head[x];i;i=e[i].to){
int k=e[i].next;
if(!e[i].v||d[k]) continue;
d[k]=d[x]+;
que.push(k);
}
}
return d[t];
} int dfs(int x,int mi){
if(x==t||!mi) return mi;
int flow=;
for(int &i=cur[x];i;i=e[i].to){
int k=e[i].next;
if(!e[i].v||d[k]!=d[x]+) continue;
int ret=dfs(k,min(mi,e[i].v));
flow+=ret;mi-=ret;
e[i].v-=ret;e[i^].v+=ret;
if(!mi) break;
}
if(mi) d[x]=-;
return flow;
} bool DINIC(int x){
int ans=;
while(bfs()){
ans+=dfs(s,INF);
}
if(ans>=n-k+) return ;
return ;
} bool check(int x){
memset(e,,sizeof(e));
memset(head,,sizeof(head));
cnt=;
for(int i=;i<=n;i++) add(s,i,);
for(int j=;j<=m;j++) add(j+n,t,);
for(int i=;i<=n;i++){
for(int j=;j<=m;j++){
if(a[i][j]<=x) add(i,j+n,INF);
}
}
if(DINIC(x)) return ;
return ;
} int main(){
//freopen("matrix.in","r",stdin);
//freopen("matrix.out","w",stdout);
n=read();m=read();k=read();
s=m+n+;t=s+;
for(int i=;i<=n;i++){
for(int j=;j<=m;j++){
a[i][j]=read();
maxn=max(maxn,a[i][j]);
}
}
int l=,r=maxn;
while(l<=r){
int mid=(l+r)>>;
if(check(mid)){
r=mid-;ans=mid;
}
else l=mid+;
}
printf("%d\n",ans);
return ;
}

题解 【SCOI2015】小凸玩矩阵的更多相关文章

  1. BZOJ 4443: [Scoi2015]小凸玩矩阵 最大流

    4443: [Scoi2015]小凸玩矩阵 题目连接: http://www.lydsy.com/JudgeOnline/problem.php?id=4443 Description 小凸和小方是好 ...

  2. 【BZOJ4443】[Scoi2015]小凸玩矩阵 二分+二分图最大匹配

    [BZOJ4443][Scoi2015]小凸玩矩阵 Description 小凸和小方是好朋友,小方给小凸一个N*M(N<=M)的矩阵A,要求小秃从其中选出N个数,其中任意两个数字不能在同一行或 ...

  3. BZOJ_4443_[Scoi2015]小凸玩矩阵_二分+二分图匹配

    BZOJ_4443_[Scoi2015]小凸玩矩阵_二分+二分图匹配 Description 小凸和小方是好朋友,小方给小凸一个N*M(N<=M)的矩阵A,要求小秃从其中选出N个数,其中任意两个 ...

  4. 2018.06.30 BZOJ4443: [Scoi2015]小凸玩矩阵(二分加二分图匹配)

    4443: [Scoi2015]小凸玩矩阵 Time Limit: 10 Sec Memory Limit: 128 MB Description 小凸和小方是好朋友,小方给小凸一个N*M(N< ...

  5. bzoj 4443 [Scoi2015]小凸玩矩阵 网络流,二分

    [Scoi2015]小凸玩矩阵 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 1564  Solved: 734[Submit][Status][Di ...

  6. bzoj 4443: [Scoi2015]小凸玩矩阵

    Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 149  Solved: 81[Submit][Status][Discuss] Description ...

  7. 图论(网络流):[SCOI2015]小凸玩矩阵

    Description 小凸和小方是好朋友,小方给小凸一个N*M(N<=M)的矩阵A,要求小秃从其中选出N个数,其中任意两个数字不能在同一行或同一列,现小凸想知道选出来的N个数中第K大的数字的最 ...

  8. 【刷题】BZOJ 4443 [Scoi2015]小凸玩矩阵

    Description 小凸和小方是好朋友,小方给小凸一个N*M(N<=M)的矩阵A,要求小秃从其中选出N个数,其中任意两个数字不能在同一行或同一列,现小凸想知道选出来的N个数中第K大的数字的最 ...

  9. 【bzoj4443】【[Scoi2015]小凸玩矩阵】二分+二分图最大匹配

    (上不了p站我要死了,侵权度娘背锅) Description 小凸和小方是好朋友,小方给小凸一个N*M(N<=M)的矩阵A,要求小秃从其中选出N个数,其中任意两个数字不能在同一行或同一列,现小凸 ...

  10. [bzoj4443] [loj#2006] [洛谷P4251] [Scoi2015]小凸玩矩阵

    Description 小凸和小方是好朋友,小方给小凸一个 \(N \times M\)( \(N \leq M\) )的矩阵 \(A\) ,要求小秃从其中选出 \(N\) 个数,其中任意两个数字不能 ...

随机推荐

  1. Educational Codeforces Round 68 (Rated for Div. 2)补题

    A. Remove a Progression 签到题,易知删去的为奇数,剩下的是正偶数数列. #include<iostream> using namespace std; int T; ...

  2. 在使用selenium时出现FileNotFoundError: [WinError 2] 系统找不到指定的文件。

    今天在使用selenium出现这样的错: Traceback (most recent call last): File "E:\python\lib\site-packages\selen ...

  3. T100——取得系统参数值,如关帐日期

    CALL cl_get_para(g_enterprise,g_site,'S-MFG-0031') RETURNING l_para_data 用此方法获取关帐日期

  4. k8s遇坑:The connection to the server k8s-api.virtual.local:6443 was refused - did you specify the right host or port?

    k8s坑The connection to the server localhost:8080 was refused - did you specify the right host or port ...

  5. nginx+keepalived高可用

    准备工作: yum install -y gcc openssl-devel pcre-devel install iptables-services setenforce 0 sed -ri 's/ ...

  6. linux 阿里云 新机器 安装jdk1.8

    2019年7月17日15:58:34 按着顺序来: wget https://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4f ...

  7. 始终让footer在底部

    1.footer保持在页面底部 需求: 我们希望footer能在窗口最底端,但是由于页面内容太少,无法将内容区域撑开,从而在 footer 下面会留下一大块空白 第一种方法:采用 flexbox布局模 ...

  8. Nginx访问限制配置

    Nginx访问限制配置 nginx访问限制可以基于两个方面,一个是基于ip的访问控制,另一个是基于用户的信任登陆控制 下面我们将对这两种方法逐个介绍 基于IP的访问控制 介绍: 可以通过配置基于ip的 ...

  9. Linux 永久挂载镜像文件和制作yum源

    Linux mount命令是经常会使用到的命令,它用于挂载Linux系统外的文件. 1.镜像挂载到系统指定目录下:[root@master cdrom]#  mount -t auto  /mnt/c ...

  10. asp.net中的比较完美的验证码

    要实现如图的效果的验证码,分以下步骤: 第一.布局好调用验证码的登录页面(命名:Login.aspx),注意:验证码位置可以是服务器控件 Image,也可以是html标签写的<img>,但 ...