这道题考察对最小点覆盖的理解。

做法:

对于一个作业,它需要A的a模式和B的b模式,那么可以从a模式向b模式连一条边;可以感性的理解为每一条边就是一个作业,需要求得有多少个模式可以覆盖所有的边,也就是最小点覆盖,也就是最大匹配。

注意 :

由于A,B的机器初始模式为0,那么所有的可以用模式0完成的工作都可以不用更换模式而完成!所以我们只需要考虑完成模式不包含0的作业。

AC代码:

 #include <vector>
#include <cstdio>
#include <cstring> const int N = + ; std :: vector < int > g [ N ] ;
int link [ N ] , n , k , m , ans , x , a , b ;
bool vis [ N ] ; void create ( int u , int v ) {
g [ u ] . push_back ( v ) ;
} bool find ( int x ) {
int v ;
for ( int i = ; i < g [ x ] . size ( ) ; i ++ ) {
v = g [ x ] [ i ] ;
if ( ! vis [ v ] ) {
vis [ v ] = true ;
if ( ( ! link [ v ] ) || find ( link [ v ] ) ) {
link [ v ] = x ;
return true ;
}
}
}
return false ;
} void init ( ) {
memset ( link , , sizeof ( link ) ) ;
ans = ;
} int main ( ) { // 待调试
while ( ) {
scanf ( "%d" , & n ) ;
if ( n == ) return ;
scanf ( "%d%d" , & m , & k ) ;
init ( ) ;
// A : 1 ~ n ;
// B : n + 1 ~ n + m ;
for ( int i = ; i <= k ; i ++ ) {
scanf ( "%d%d%d" , & x , & a , & b ) ;
if ( a * b != ) create ( a , b + n ) ;
}
for ( int i = ; i <= n ; i ++ ) {
memset ( vis , false , sizeof ( vis ) ) ;
if ( find ( i ) )
ans ++ ;
}
printf ( "%d\n" , ans ) ;
for ( int i = ; i <= n + m ; i ++ )
g [ i ] . clear ( ) ;
}
}

AC

POJ 1235 Machine Schedule 【二分图】的更多相关文章

  1. POJ - 1325 Machine Schedule 二分图 最小点覆盖

    题目大意:有两个机器,A机器有n种工作模式,B机器有m种工作模式,刚開始两个机器都是0模式.假设要切换模式的话,机器就必须的重新启动 有k个任务,每一个任务都能够交给A机器的i模式或者B机器的j模式完 ...

  2. POJ 1325 Machine Schedule——S.B.S.

    Machine Schedule Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 13731   Accepted: 5873 ...

  3. poj 1325 Machine Schedule 二分匹配,可以用最大流来做

    题目大意:机器调度问题,同一个任务可以在A,B两台不同的机器上以不同的模式完成.机器的初始模式是mode_0,但从任何模式改变成另一个模式需要重启机器.求完成所有工作所需最少重启次数. ======= ...

  4. poj 1325 Machine Schedule 题解

    Machine Schedule Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 14479   Accepted: 6172 ...

  5. ZOJ 1364 Machine Schedule(二分图最大匹配)

    题意 机器调度问题 有两个机器A,B A有n种工作模式0...n-1 B有m种工作模式0...m-1 然后又k个任务要做 每一个任务能够用A机器的模式i或b机器的模式j来完毕 机器開始都处于模式0 每 ...

  6. HDU - 1150 POJ - 1325 Machine Schedule 匈牙利算法(最小点覆盖)

    Machine Schedule As we all know, machine scheduling is a very classical problem in computer science ...

  7. poj 1325 Machine Schedule 最小点覆盖

    题目链接:http://poj.org/problem?id=1325 As we all know, machine scheduling is a very classical problem i ...

  8. poj 1325 Machine Schedule

    Time Limit: 1000 MS Memory Limit: 10000 KB 64-bit integer IO format: %I64d , %I64u   Java class name ...

  9. HDU1150 Machine Schedule(二分图最大匹配、最小点覆盖)

    As we all know, machine scheduling is a very classical problem in computer science and has been stud ...

随机推荐

  1. python apache下出现The _imaging C module is not installed

    操作系统:win7 64位 安装python版本 win32 2.7版本 安装的PIL插件PIL-1.1.7.win32-py2.7.exe 用本地自带的开发服务器上传图片处理等一切正常 放到APAC ...

  2. 3D打印材料的发展现状(1)

    材料是3D打印的物质基础,也是当前制约3D打印发展的瓶颈. 3D打印材料 3D打印材料是3D打印技术发展的重要物质基础,材料的发展对于3D打印的发展有重要的作用. 目前,3D打印材料主要包括工程塑料. ...

  3. JSP九大内置对象与Servlet的对应关系

    JSP对象                              Servlet中怎样获得 request service方法中的request参数 response service方法中的res ...

  4. Mysql性能监控项及sql语句

    推荐一款mysql监控软件MONyog 1.查询缓存: mysql> show variables like '%query_cache%'; 2.缓存在Cache中线程数量thread_cac ...

  5. [VS2015] [asp.net] 允许远程访问本机正在DEBUG的服务

    一.打开并编辑解决方案目录(不是工程目录)下的文件: \.vs\config\applicationhost.config 增加黑体行: <site name="XXXX" ...

  6. [翻译] SAMCoreImageView

    SAMCoreImageView https://github.com/soffes/SAMCoreImageView Render a CIImage in an OpenGL thingy so ...

  7. (转)如何安装 easy installer+pip

    http://blog.csdn.net/wuxiaobingandbob/article/details/42457807

  8. ASP.NET MVC 5 开发环境配置

    Install-Package Ninject -Version 3.2.2 -ProjectName SportsStore.WebUIInstall-Package Ninject.Web.Com ...

  9. Lonely(非洲NANA作品)

    Lonely(非洲NANA作品) 编辑 Lonely NANA,出生于1968年10月5日的非洲加纳.来自于加纳的NANA出身于一个富有的家庭,但是父亲在他小时候离他们而去,母亲带着年幼的NANA定居 ...

  10. libcurl同时下载多个文件

    #include <errno.h> #include <stdlib.h> #include <string.h> #ifndef WIN32 #include ...