题意:

有n(n<500)台机器,和500个程序。不同的程序在不同的机器上运行有着不同的不稳定度s[i][j]。求最小的最大稳定度及其方案。


Solution:

比较经典的二分图模型。

建图很简单。直接将$s[i][j]$作为图的邻接矩阵。

看到求最小的最大稳定度,想到二分答案。

check的话,只要利用所有小于等于当前二分的$ans$的边求二分图的最大匹配。如果$ 最大匹配=n $ 那么当前解是可行的。

十分要注意的是权值可能为负!

#include <iostream>
#include <cstring>
#include <cstdio> using namespace std;
const int N = 501;
int link[N], vis[N];
int G[N][N],ans[N];
int n, mid;
bool DFS ( int x )
{
for ( int i = 1; i <= n; i++ )
if ( G[x][i] <= mid && !vis[i] ) {
vis[i] = 1;
if ( link[i] == -1 || DFS ( link[i] ) ) {
link[i] = x;
return 1;
}
}
return 0;
}
bool check()
{
int ans = 0;
memset ( link, -1, sizeof link );
for ( int i = 1; i <= n; i++ ) {
memset ( vis, 0, sizeof vis );
if ( DFS ( i ) ) ans++;
}
return ans == n;
}
int main()
{
scanf ( "%d", &n );
for ( int i = 1; i <= n; ++i ) {
for ( int j = 1; j <= n; ++j ) {
scanf ( "%d", &G[i][j] );
}
}
int l = -int(1e6), r = int ( 1e6 );
while ( l <= r ) {
mid = ( l + r ) >> 1;
if ( check () ) r = mid - 1;
else
l = mid + 1;
}
printf ( "%d\n", r + 1 );
mid = r + 1;
check();
for ( int i = 1; i <= n; ++i ) {
ans[link[i]]=i;
}
for ( int i = 1; i <= n; ++i ) {
printf ( "%d %d\n", i, ans[i] );
}
}
/*
3
100 1 100
100 100 1
1 100 100
*/

SGU 218.Unstable Systems的更多相关文章

  1. Gromacs命令-Chapter1

    Gromacs的命令非常多,下面我将我最近用到的先总结一下.标题上也写了这只是Chapter1,以后有新的会继续写Chapter2...等等. 下面这个网址http://manual.gromacs. ...

  2. 【SGU 390】Tickets (数位DP)

    Tickets   Description Conductor is quite a boring profession, as all you have to do is just to sell ...

  3. Virtualization solutions on Linux systems - KVM and VirtualBox

    Introduction Virtualization packages are means for users to run various operating systems without &q ...

  4. Methods and systems for sharing common job information

    Apparatus and methods are provided for utilizing a plurality of processing units. A method comprises ...

  5. PatentTips - Systems, methods, and devices for dynamic resource monitoring and allocation in a cluster system

    BACKGROUND  1. Field  The embodiments of the disclosure generally relate to computer clusters, and m ...

  6. Single-stack real-time operating system for embedded systems

    A real time operating system (RTOS) for embedded controllers having limited memory includes a contin ...

  7. Android Weekly Notes Issue #218

    Android Weekly Issue #218 August 14th, 2016 http://androidweekly.net/issues/issue-218 ARTICLES & ...

  8. Modern Operating Systems(Ⅰ)——2014.12.15

    进程   进程模型     进程就是一个正在执行的程序的实例  值得注意的是,若一个程序运行了两遍,则算作两个进程 创建进程 在通用系统中,有四种主要事件导致进程的创建 ①系统的初始化 ②执行了 正在 ...

  9. 【转载】Bandits for Recommendation Systems (Part I)

    [原文链接:http://engineering.richrelevance.com/bandits-recommendation-systems/.] [本文链接:http://www.cnblog ...

随机推荐

  1. POJ2739 - Sum of Consecutive Prime Numbers(素数问题)

    题目大意 给定N,要求你计算用连续的素数的和能够组成N的种数 题解 先筛选出素数,然后暴力判断即可... 代码: #include<iostream> #include<cstrin ...

  2. Redis在PHP中的基本使用案例

    下载http://www.oschina.net/p/redis 解压后里面有:lib 源文件 .examples 例子.test测试 将lib目录拷贝到你的项目中,就可以开始你的predis操作了. ...

  3. JavaScript constructors, prototypes, and the `new` keyword

    Are you baffled(阻碍:使迷惑) by the new operator in JavaScript? Wonder what the difference between a func ...

  4. 来自奢侈品行业的CEO能给苹果带来什么?

    重回苹果的奢侈品大佬:保罗丹诺威 作为伊夫·圣罗兰(Saint Laurent)时尚集团的前CEO,保罗丹诺威(Paul Deneve)9月将正式加入苹果公司,并负责该公司所谓的“特殊项目”,同时直接 ...

  5. github上值得关注的前端项目

    https://segmentfault.com/a/1190000002804472

  6. easyui datagrid用formtater的问题

    当value是一个字符串是直接使用value会提示value没有定义,这时需要转换下value,用""+value来替换就可以了.

  7. 聊聊LAA(LARGE ADDRESS AWARE)

    博客搬到了fresky.github.io - Dawei XU,请各位看官挪步.最新的一篇是:聊聊LAA(LARGE ADDRESS AWARE).

  8. 从bug中学习怎么写代码

    博客搬到了fresky.github.io - Dawei XU,请各位看官挪步.最新的一篇是:从bug中学习怎么写代码.

  9. iOS ipv6

    这当中最重要的两个概念是DNS64和NAT64. DNS64 DNS64说白了是用来帮助host获取IPv6地址的,传统的DNS服务器可以把域名转换成IPv4地址,但我们的iPhone设备如果处于IP ...

  10. SpringMVC学习系列 之 表单标签

    http://www.cnblogs.com/liukemng/p/3754211.html 本篇我们来学习Spring MVC表单标签的使用,借助于Spring MVC提供的表单标签可以让我们在视图 ...