题目链接

问题分析

题目给了充足的暗示,我们只需要二分答案然后跑匈牙利即可。要相信匈牙利的速度

参考程序

#include <bits/stdc++.h>
using namespace std; const int Maxn = 310;
const int INF = 2147483647;
int N, M, K, A[ Maxn ][ Maxn ], Max, Min;
int Map[ Maxn ][ Maxn ], Vis[ Maxn ], Mx[ Maxn ], My[ Maxn ]; int Dfs( int x ) {
for( int i = 1; i <= M; ++i ) {
if( Map[ x ][ i ] == 0 ) continue;
if( Vis[ i ] ) continue;
Vis[ i ] = 1;
if( My[ i ] == 0 || Dfs( My[ i ] ) ) {
Mx[ x ] = i; My[ i ] = x;
return 1;
}
}
return 0;
} bool Check( int Mid ) {
memset( Map, 0, sizeof( Map ) );
memset( Mx, 0, sizeof( Mx ) );
memset( My, 0, sizeof( My ) );
for( int i = 1; i <= N; ++i )
for( int j = 1; j <= M; ++j )
if( A[ i ][ j ] <= Mid ) Map[ i ][ j ] = 1;
int Ans = 0;
for( int i = 1; i <= N; ++i ) {
memset( Vis, 0, sizeof( Vis ) );
Ans += Dfs( i );
}
return Ans >= ( 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", &A[ i ][ j ] );
Max = 0, Min = INF;
for( int i = 1; i <= N; ++i )
for( int j = 1; j <= M; ++j )
Max = max( A[ i ][ j ], Max ), Min = min( A[ i ][ j ], Min );
int Ans = 0;
while( Max >= Min ) {
int Mid = ( Max + Min ) >> 1;
if( Check( Mid ) ) Ans = Mid, Max = Mid - 1; else Min = Mid + 1;
}
printf( "%d\n", Ans );
return 0;
}

最新文章

  1. 浅谈WebLogic和Tomcat
  2. IOS 绘图教程Quartz2D
  3. poj 3262 Protecting the Flowers
  4. JavaScript继承
  5. Apache 日志管理,获取客户端端口号
  6. LVS ip-tun服务器脚本
  7. mongodb(二) 安装和使用
  8. SQL SERVER 服务启动后停止,某些服务由其它服务或程序使用时将自动停止
  9. sublime返回上一编辑位置
  10. oracl使用DataBase Configuration Assistant创建、删除数据库
  11. HTML (1)href与Action,get post
  12. (转).net开发者对android开发一周的学习体会
  13. JQuery中回车键登陆
  14. codeforces 782B The Meeting Place Cannot Be Changed (三分)
  15. Centos7-卸载自带的jdk 安装jdk8
  16. 《An Introduction to Signal Smoothing》译文
  17. Socket实现聊天客户端
  18. Leetcode中sort排序遇到的一些问题
  19. 收藏一个带动画效果的ScrollViewer以及ScrollBar的模板
  20. Python 扫盲

热门文章

  1. Spring Boot+CXF搭建WebService服务参考资料
  2. (电脑重置之后)win10在桌面点右键鼠标一直转圈;无法点击桌面图标;
  3. 【NOIP2017】跳房子
  4. 精选 TOP 面试题
  5. 【原创】运维基础之Nginx(3)location和rewrite
  6. qt webengineview 设置背景颜色
  7. NGINX工作原理(2)
  8. LLVM源码安装教程
  9. MyCat配置简述以及mycat全局ID
  10. 13、Nginx七层负载均衡