当前位置:网站首页>P4251 [scoi2015] small convex play matrix (still a little confused)
P4251 [scoi2015] small convex play matrix (still a little confused)
2022-06-27 16:30:00 【Zhong Zhongzhong】
https://www.luogu.com.cn/problem/P4251
Two points answer + Minimum match
You need to determine : Can you find out at least n-k+1 Number , Make these numbers not greater than the current value and satisfy the condition .
seek n The number of k The minimum of a large number --------- Two points answer
Select a number per line ----------------------- Bipartite graph can be established
The first k The minimum of a large number ----------- Two points make a second k Large number , Find the maximum matching number , If the maximum match is greater than n-k, It means that this number can be even smaller , Reduce the boundary of the dichotomy .
#include <bits/stdc++.h>
using namespace std;
const int inf=0x3f3f3f3f;
const int maxn=1e5+5;
int n,m,k,mp[300][300],link[maxn],head[maxn];
bool used[maxn];
int cnt,ma=0,mi=inf;
struct node
{
int to,nxt;
}e[maxn];
void add(int from,int to)
{
e[++cnt].to=to;
e[cnt].nxt=head[from];
head[from]=cnt;
}
bool dfs(int u)
{
for(int i=head[u];i!=-1;i=e[i].nxt)
{
int v=e[i].to;
if(!used[v])
{
used[v]=1;
if(link[v]==-1||dfs(link[v]))
{
link[v]=u;
return 1;
}
}
}
return 0;
}
bool pd(int mid)
{
memset(link,-1,sizeof(link));
memset(head,-1,sizeof(head));
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
if(mp[i][j]<=mid)
add(i,j+n);
}
}
int res=0;
for(int i=1;i<=n;i++)
{
memset(used,0,sizeof(used));
if(dfs(i))
res++;
}
return res>=n-k+1;
}
int main()
{
scanf("%d%d%d",&n,&m,&k);
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
scanf("%d",&mp[i][j]);
ma=max(ma,mp[i][j]);
mi=min(mi,mp[i][j]);
}
}
int l=mi,r=ma,mid,ans;
while(l<=r)
{
mid=(l+r)>>1;
if(pd(mid))
r=mid-1,ans=mid;
else
l=mid+1;
}
cout<<ans<<endl;
return 0;
}
边栏推荐
- EMQ 助力青岛研博建设智慧水务平台
- What should the ultimate LAN transmission experience be like
- Scrapy framework (I): basic use
- 一个机器人位于一个 m x n 网格的左上角 。机器人每次只能向下或者向右移动一步。机器人试图达到网格的右下角。问总共有多少条不同的路径?【LeetCodeHot100】
- Construction and management practice of ByteDance buried point data flow
- Bit.Store:熊市漫漫,稳定Staking产品或成主旋律
- 泰山OFFICE技术讲座:第一难点是竖向定位
- 鸿蒙发力!HDD杭州站·线下沙龙邀您共建生态
- Julia constructs diagonal matrix
- A distribution fission activity is more than just a circle of friends!
猜你喜欢

【牛客刷题】NowCoder号称自己已经记住了1-100000之间所有的斐波那契数。 为了考验他,我们随便出一个数n,让他说出第n个斐波那契数。如果第n个斐波那契大于6位则只取后6位。

关于#mysql#的问题:问题遇到的现象和发生背景

智慧风电 | 图扑软件数字孪生风机设备,3D 可视化智能运维

#yyds干货盘点# 解决剑指offer:二叉树中和为某一值的路径(三)
A large number of missing anchor text

3.2 multiple condition judgment

防火墙基础之源NAT地址转换和服务器映射web页面配置

Open source 23 things shardingsphere and database mesh have to say

10分钟掌握mysql的安装步骤

Weekly snapshot of substrate technology 20220411
随机推荐
National food safety risk assessment center: do not blindly and unilaterally pursue "zero addition" and "pure natural" food
Julia constructs diagonal matrix
[pygame Games] ce jeu "eat Everything" est fantastique? Tu manges tout? (avec code source gratuit)
Hierarchical clustering and case analysis
C语言课程设计
EMQ 助力青岛研博建设智慧水务平台
数据中心表格报表实现定制统计加班请假汇总记录分享
The interview lasted for half a year. Last month, I successfully got Alibaba p7offer. It was all because I chewed the latest interview questions in 2020!
Mobile terminal click penetration
Special function calculator
After the mobile phone, it was reported that Samsung also cut the output of TV and other home appliance product lines
模拟进程调度
泰山OFFICE技术讲座:第一难点是竖向定位
Redis Series 2: data persistence improves availability
Regular matching starts with what, ends with what, starts with what, and ends with what
What is RPC
关于#mysql#的问题:问题遇到的现象和发生背景
LeetCode每日一练(无重复字符的最长子串)
QT5 之信号与槽机制(信号与槽的基本介绍)
Introduce you to ldbc SNB, a powerful tool for database performance and scenario testing