题目链接:传送门

题目大意:有k个任务,可以在 A 机器的 x 位上完成,也可以在 B 机器的 y 位上完成。问最少需要多少个点位即可完成所有任务。

题目思路:求最小点覆盖。

     把 A 机器,B 机器看做两个集合,任务需要的点位即可看做 A,B 之间的边,要最少点位,也就是要最少的点覆盖完所有的边。

     二分图匹配即可(二分图 最小点覆盖==最大匹配数)

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <stack>
#include <cctype>
#include <queue>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <climits>
#define lson rt<<1,l,mid
#define rson rt<<1|1,mid+1,r
#define fi first
#define se second
#define ping(x,y) ((x-y)*(x-y))
#define mst(x,y) memset(x,y,sizeof(x))
#define mcp(x,y) memcpy(x,y,sizeof(y))
using namespace std;
#define gamma 0.5772156649015328606065120
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define N 1505
#define maxn 500005
typedef pair<int,int> PII;
typedef long long LL; int n,k,m,ans,S,T,hcnt;
int pic[][];
int vis[],lik[];
int dfs(int x){
for(int i=;i<=m;++i){
if(pic[x][i]&&!vis[i]){
vis[i]=;
if(lik[i]==-||dfs(lik[i])){
lik[i]=x;
return ;
}
}
}
return ;
}
void xyl(){
mst(lik,-);
for(int i=;i<=n;++i){
mst(vis,);
ans+=dfs(i);
}
}
int main(){
int i,j,group,x,y,v,id;
while(scanf("%d",&n)!=EOF&&n){
mst(pic,);
scanf("%d%d",&m,&k);
for(i=;i<=k;++i){
scanf("%d%d%d",&v,&x,&y);
pic[x][y]=;
}
ans=;
xyl();
printf("%d\n",ans);
}
return ;
}

poj1325(Machine Schedule)的更多相关文章

  1. 我在 B 站学机器学习(Machine Learning)- 吴恩达(Andrew Ng)【中英双语】

    我在 B 站学机器学习(Machine Learning)- 吴恩达(Andrew Ng)[中英双语] 视频地址:https://www.bilibili.com/video/av9912938/ t ...

  2. 人工智能(Machine Learning)—— 机器学习

    https://blog.csdn.net/luyao_cxy/article/details/82383091 转载:https://blog.csdn.net/qq_27297393/articl ...

  3. 机器学习(Machine Learning)

    机器学习(Machine Learning)是一门专门研究计算机怎样模拟或实现人类的学习行为,以获取新的知识或技能,重新组织已有的知识结构使之不断改善自身的性能的学科.

  4. Domain adaptation:连接机器学习(Machine Learning)与迁移学习(Transfer Learning)

    domain adaptation(域适配)是一个连接机器学习(machine learning)与迁移学习(transfer learning)的新领域.这一问题的提出在于从原始问题(对应一个 so ...

  5. 学习笔记之机器学习(Machine Learning)

    机器学习 - 维基百科,自由的百科全书 https://zh.wikipedia.org/wiki/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0 机器学习是人工智能的一个分 ...

  6. 【Poj1325】Machine Schedule机器调度

    目录 List Description Input Output Sample Input Sample Output HINT Solution Code Position: http://poj. ...

  7. 机器学习( Machine Learning)的定义

    关于机器学习有两个相关的定义: 1)给计算机赋予没有固定编程的学习能力的研究领域. 2)一种计算机的程序,能从一些任务(T)和性能的度量(P),经验(E)中进行学习.在学习中,任务T的性能P能够随着P ...

  8. 机器学习(Machine Learning)算法总结-K临近算法

    一.算法详解 1.什么是K临近算法 Cover 和 Hart在1968年提出了最初的临近算法 属于分类(classification)算法 邻近算法,或者说K最近邻(kNN,k-NearestNeig ...

  9. 机器学习(Machine Learning)算法总结-决策树

    一.机器学习基本概念总结 分类(classification):目标标记为类别型的数据(离散型数据)回归(regression):目标标记为连续型数据 有监督学习(supervised learnin ...

随机推荐

  1. 使用 WinEdt 来写中文文章or 建模论文

    找了几乎两个小时…… 后来发现… WinEdt 是可以用来写中文文章的…而并非只能英文文章或演示文稿… \documentclass{article} \usepackage{CJK} \begin{ ...

  2. hudson status

    http://sin90lzc.iteye.com/blog/1072123在eclipse上显示hudson构建状态 update site:http://eclipse-plugin-potpou ...

  3. asp.net mvc easyui datagrid分页

    提到 asp.net mvc 中的分页,很多是在用aspnetpager,和easyui datagrid结合的分页却不多,本文介绍的是利用easyui 中默认的分页控件,实现asp.net mvc分 ...

  4. 读取properties属性文件——国际化

    public class PropertiesInfo { /** * PropertiesInfo实例 */ private static PropertiesInfo pi = null; pri ...

  5. 转:BOOTSTRAP 增加、关闭、折叠TAB代码下载

    http://git.oschina.net/hbbcs/bootStrap-addTabs

  6. freeswitch 音 视频 支持的编码

    FreeSWITCH 支持很多的语音编解码:[13] PCMU – G.711 µ-law PCMA – G.711 A-law G.722 G.722.1 G.722.1c G.726 G.726  ...

  7. blender,沿某一轴缩放

    scale是等比缩放,要想沿某一轴缩放按一下s+z,或s+x,或s+y.

  8. CENTOS 下安装APK反编译工具 APKTOOL

    转于:http://www.qiansw.com/centos-apk-apktool.html 我使用的是CentOS6.4 64位的系统.首先需要下载两个包.这里下载:https://code.g ...

  9. jsp中跳出循环

    <c:otherwise> <c:set var="flag" value="true" /><!-- 设置flag --> ...

  10. 跟着百度学PHP[14]-PDO的预处理语句1

    预处理语句有以下两个特点: 1.效率高 2.安全性好 为什么说预处理语句效率高呢? 预处理语句就好比一个模板,比如下面的一串插入语句: insert into admin(id,username,pa ...