题意:

有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. HDOJ-ACM1011(JAVA)

    转载声明:原文转自:http://www.cnblogs.com/xiezie/p/5569721.html 搞懂题意之后,个人感觉,这道题题目的描述相当的费解~ 做这道题目,个人感觉,涉及到树的遍历 ...

  2. C++中字符串的结尾标志\0

    \0是C++中字符串的结尾标志,存储在字符串的结尾,它虽然不计入串长,但要占一个字节的内存空间.在百度百科中查看\0词条,会有这样一句话:c/c++中规定字符串的结尾标志为'\0'.有人可能认为,在C ...

  3. 10个强大的Apache开源模块

    1.单点登录模块 LemonLDAP LemonLdap可以很棒地实现Apache的SSO功能,并且可以处理超过 20 万的用户请求.LemonLdap支持Java, PHP, .Net, Perl, ...

  4. FFT(快速傅立叶算法 for java)

    package com.test.test2; public class FFT {     public static final int FFT_N_LOG = 10; // FFT_N_LOG ...

  5. Emmet:一个Html/Css快速编辑神器的插件

    一.介绍:Emmet的前身是大名鼎鼎的Zen coding,如果你从事Web前端开发的话,对该插件一定不会陌生.它使用仿CSS选择器的语法来生成代码,大大提高了HTML/CSS代码编写的速度 二.使用 ...

  6. zend studio-如何更改字符集

    在加载一个项目的过程中很时候会因为字符集的不匹配从而导致项目文件显示为乱码,zend studio开发工具应该如何设置字符集呢: 打开[windows]-[preference]-[workspace ...

  7. cardslib

    https://github.com/gabrielemariotti/cardslib

  8. 为Windows 7的winsxs目录瘦身,谨慎。

    刚使用Win7 系统不久,前段时间在清理系统垃圾时发现,win7系统的windows文件夹下的winsxs 文件夹占用空间很大,想清理之,却提示无权限无法清理.随即在网上查了个到底,原来winsxs是 ...

  9. linux shell read command-Getting User Input Via Keyboard--ref

    ref:http://bash.cyberciti.biz/guide/Getting_User_Input_Via_Keyboard You can accept input from the ke ...

  10. android的activity的跳转

    1.无参数的跳转 先在layout下建立一个factivity.xml,在里面添加2个Button按钮和一个TextView,并添加属性 , 然后建立以个sactivity.xml文件, 在src下建 ...