题意:

有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. HW2.20

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  2. cloud-utils cloud-utils-growpart cloud-init

  3. iptables与tcpdump谁更靠近网卡

    结论是tcpdump,用tcpdump抓包试试就知道了. // 将所有访问8080端口的包丢弃 iptables -A INPUT -s -j DROP // 查看iptables的策略 iptabl ...

  4. Git学习资料

    1.http://wuyuans.com/2012/05/github-simple-tutorial/ 2.http://www.ihref.com/read-16369.html

  5. Java开发中常见的危险信号(中)

    本文来源于我在InfoQ中文站原创的文章,原文地址是:http://www.infoq.com/cn/news/2013/12/common-red-flags-in-java-1 Dustin Ma ...

  6. Mybatis上路_05-使用命令行自动生成

    http://my.oschina.net/vigiles/blog/125127 目录[-] 1.数据准备: 1)建库: 2)建表: 3)预设数据: 2.编写Generator执行配置文件: 3.搭 ...

  7. linux-多线程

    一.什么是线程? 线程是进程的一个实体,是CPU调度和分派的基本单位,它是比进程更小的能独立执行的基本单位.线程自己基本上不拥有系统资源,仅仅拥有一点在执行中不可缺少的资源(如程序计数器,一组寄存器和 ...

  8. HDU 4465 - Candy(概率与数学优化)

    2012成都Regional的B题,花了一个小时推出了式子,但是搞了好久发现都控制不了精度,后来突然想到组合数可以用log优化,改了之后就AC了 比较水的概率题 #include <stdio. ...

  9. [转]JavaScript作用域安全构造函数

          构造函数其实就是一个使用new操作符调用的函数.当使用new调用时,构造函数内用到的this对象会对指向新创建的对象实例,如下的例子所示: function Person(name, ag ...

  10. C# Obsolete

    Obsolete 属性将某个程序实体标记为一个建议不再使用的实体.每次使用被标记为已过时的实体时,随后将生成警告或错误,这取决于属性是如何配置的 如果把false 改成 true 的话那么GetNam ...