当前位置:网站首页>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;
}
边栏推荐
- Scrapy framework (I): basic use
- 事务的隔离级别详解
- Solving Poisson equation by tensorflow
- C language teacher workload management system
- Openssf security plan: SBOM will drive software supply chain security
- 锚文本大量丢失的问题
- What is the level 3 password complexity of ISO? How often is it replaced?
- 华为云DevCloud重磅发布四大新能力,创下国内两项第一
- 【Pygame小游戏】这款“吃掉一切”游戏简直奇葩了?通通都吃掉嘛?(附源码免费领)
- Event listening mechanism
猜你喜欢
P. Simple application of a.r.a method in Siyuan (friendly testing)
锚文本大量丢失的问题

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

Etcd可视化工具:Kstone部署(一),基于Helm快速部署

Four characteristics of transactions

#yyds干货盘点# 解决剑指offer:二叉树中和为某一值的路径(三)

Redis Series 2: data persistence improves availability

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

What is RPC

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
随机推荐
Bit.Store:熊市漫漫,稳定Staking产品或成主旋律
C語言教師工作量管理系統
MySQL中符号@的作用
LeetCode每日一练(主要元素)
10分钟掌握mysql的安装步骤
Introduce you to ldbc SNB, a powerful tool for database performance and scenario testing
About how vs2019c # establishes the login interface, the user name and password entered must match the records in the access database
华为云首次解读云原生2.0十大典型架构,加速构建现代化应用
请问阿里云实验中 k8s 对于3306端口转发,同时开启mysql客户端就会异常终止,是什么原因呢?
Google Earth Engine(GEE)——Export. image. The difference and mixing of toasset/todrive, correctly export classification sample data to asset assets and references
[pyGame games] this "eat everything" game is really wonderful? Eat them all? (with source code for free)
Etcd visualization tool: kstone deployment (I), rapid deployment based on Helm
Four characteristics of transactions
Yyds dry inventory brief chrome V8 engine garbage collection
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
是不是只要支持JDBC / ODBC协议的客户端恐惧,PolarDB-X可通过相关工具的客户端访问?
Practice of constructing ten billion relationship knowledge map based on Nebula graph
Sigkdd22 | graph generalization framework of graph neural network under the paradigm of "pre training, prompting and fine tuning"
QT audio playback upgrade (7)