The K-Large is n-k+1 small, so you can answer the two points (Jianggo said a similar question)
The two-point answer finds the coordinates of the position of the number that is smaller than the current answer, determines whether the n-k+1 number that satisfies the same column in the same row can be selected, and then runs Hungary, and for a coordinate (x, y) if the current answer to A[x][y]≤a[x][y is met, the line x is connected to the Y column, Then run Hungary to determine if the maximum match is greater than n-k+1
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
#include<set>
using
namespace
std;
#define M 300
#define N 1000001
struct
edge
{
int
v,next;
}e[N<<1];
int
head[N<<1];
int
cnt;
int
map[M][M];
int
ly[N],f[N];
int
n,m,k;
int
l,r;
int
maxn,tot,ans;
void
link(
int
x,
int
y)
{
e[++cnt]=(edge){y,head[x]};
head[x]=cnt;
}
bool
find(
int
d)
{
for
(
int
i=head[d];i;i=e[i].next)
{
int
t=e[i].v;
if
(ly[t]!=tot)
{
ly[t]=tot;
if
(!f[t] || find(f[t]))
{
f[t]=d;
return
true
;
}
}
}
return
false
;
}
int
work(
int
x)
{
ans=cnt=0;
memset
(head,0,
sizeof
(head));
memset
(f,0,
sizeof
(f));
for
(
int
i=1;i<=n;i++)
for
(
int
j=1;j<=m;j++)
if
(map[i][j]<=x)
link(i,j);
for
(
int
i=1;i<=n;i++)
{
tot++;
ans+=find(i);
}
return
ans>=k ? 1: 0;
}
int
main()
{
scanf
(
"%d%d%d"
,&n,&m,&k);
k=n-k+1;
for
(
int
i=1;i<=n;i++)
for
(
int
j=1;j<=m;j++)
scanf
(
"%d"
,&map[i][j]),maxn=max(maxn,map[i][j]);
l=1;
r=maxn;
while
(l<r)
{
int
m=l+r>>1;
if
(work(m))
r=m;
else
l=m+1;
}
printf
(
"%d\n"
,l);
return
0;
}
"bzoj4443" [Scoi2015] small convex play matrix