当前位置:网站首页>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;
}
边栏推荐
- Qt5 signal and slot mechanism (demonstrate the correlation between the control's own signal and slot function)
- Weekly snapshot of substrate technology 20220411
- 事务的四大特性
- Jialichuang EDA professional edition all offline client release
- 当发布/订阅模式遇上.NET
- LeetCode每日一练(主要元素)
- 鸿蒙发力!HDD杭州站·线下沙龙邀您共建生态
- What is RPC
- NFT双币质押流动性挖矿dapp合约定制
- 关于VS2019C#如何建立登陆界面输入的用户名和密码需与Access数据库的记录相匹配
猜你喜欢

Hongmeng makes efforts! HDD Hangzhou station · offline salon invites you to build ecology

What is RPC

Data center table reports realize customized statistics, overtime leave summary record sharing

数据中心表格报表实现定制统计加班请假汇总记录分享

Weekly snapshot of substrate technology 20220411

Raspberry pie preliminary use

A robot is located in the upper left corner of an M x n grid. The robot can only move down or right one step at a time. The robot attempts to reach the lower right corner of the grid. How many differe

【Pygame小遊戲】這款“吃掉一切”遊戲簡直奇葩了?通通都吃掉嘛?(附源碼免費領)

The two trump brand products of Langjiu are resonating in Chengdu, continuously driving the consumption wave of bottled liquor

#yyds干货盘点# 解决剑指offer:二叉树中和为某一值的路径(三)
随机推荐
数据中心表格报表实现定制统计加班请假汇总记录分享
LeetCode每日一练(主要元素)
Qt5 signal and slot mechanism (demonstrate the correlation between the control's own signal and slot function)
C语言集合运算
C language teacher workload management system
特殊函数计算器
[Niuke's questions] nowcoder claims to have remembered all Fibonacci numbers between 1 and 100000. To test him, we gave him a random number N and asked him to say the nth Fibonacci number. If the nth
3.4 fixed number of cycles II
ICML 2022 ぷ the latest fedformer of the Dharma Institute of Afghanistan ⻓ surpasses SOTA in the whole process of time series prediction
In the Alibaba cloud experiment, if the k8s forwards to port 3306 and the MySQL client is turned on, it will terminate abnormally. What is the reason?
Huawei cloud devcloud launched four new capabilities, setting two domestic firsts
Sliding window + monotone queue concept and example (p1886 Logu)
Domain name binding dynamic IP best practices
LeetCode每日一练(无重复字符的最长子串)
Regular matching starts with what, ends with what, starts with what, and ends with what
等保2.0密码要求是什么?法律依据有哪些?
Markdown syntax
Handling of difficult and miscellaneous problems during the installation and configuration of qt5.5.1 desktop version (configuring arm compilation Kit)
SQL parsing practice of Pisa proxy
Practice of constructing ten billion relationship knowledge map based on Nebula graph