poj1325(Machine Schedule)
题目链接:传送门
题目大意:有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)的更多相关文章
- 我在 B 站学机器学习(Machine Learning)- 吴恩达(Andrew Ng)【中英双语】
我在 B 站学机器学习(Machine Learning)- 吴恩达(Andrew Ng)[中英双语] 视频地址:https://www.bilibili.com/video/av9912938/ t ...
- 人工智能(Machine Learning)—— 机器学习
https://blog.csdn.net/luyao_cxy/article/details/82383091 转载:https://blog.csdn.net/qq_27297393/articl ...
- 机器学习(Machine Learning)
机器学习(Machine Learning)是一门专门研究计算机怎样模拟或实现人类的学习行为,以获取新的知识或技能,重新组织已有的知识结构使之不断改善自身的性能的学科.
- Domain adaptation:连接机器学习(Machine Learning)与迁移学习(Transfer Learning)
domain adaptation(域适配)是一个连接机器学习(machine learning)与迁移学习(transfer learning)的新领域.这一问题的提出在于从原始问题(对应一个 so ...
- 学习笔记之机器学习(Machine Learning)
机器学习 - 维基百科,自由的百科全书 https://zh.wikipedia.org/wiki/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0 机器学习是人工智能的一个分 ...
- 【Poj1325】Machine Schedule机器调度
目录 List Description Input Output Sample Input Sample Output HINT Solution Code Position: http://poj. ...
- 机器学习( Machine Learning)的定义
关于机器学习有两个相关的定义: 1)给计算机赋予没有固定编程的学习能力的研究领域. 2)一种计算机的程序,能从一些任务(T)和性能的度量(P),经验(E)中进行学习.在学习中,任务T的性能P能够随着P ...
- 机器学习(Machine Learning)算法总结-K临近算法
一.算法详解 1.什么是K临近算法 Cover 和 Hart在1968年提出了最初的临近算法 属于分类(classification)算法 邻近算法,或者说K最近邻(kNN,k-NearestNeig ...
- 机器学习(Machine Learning)算法总结-决策树
一.机器学习基本概念总结 分类(classification):目标标记为类别型的数据(离散型数据)回归(regression):目标标记为连续型数据 有监督学习(supervised learnin ...
随机推荐
- (十)Unity5.0新特性------新UI系统实战
原文 Unity New GUI Tutorial – Part 1 Unity New GUI Tutorial- Part 2 Unity New GUI Tutorial – Part 3 大家 ...
- iOS 9应用开发教程之ios9中实现button的响应
iOS 9应用开发教程之ios9中实现button的响应 IOS9实现button的响应 button主要是实现用户交互的.即实现响应.button实现响应的方式能够依据加入button的不同分为两种 ...
- tcp_recvmsg 函数具体解释
看了非常多网上关于tcp_recvmsg的文章,感觉解释的不太到位,或者非常多都是空口说白话,昨天分析了一下午tcp_recvmsg.感觉了解了十之八九,如今贴出来和大家分享一下. 须要背景:了解tc ...
- PyCharm设置python新建文件指定编码为utf-8
PyCharm新建文件时可以在模板中添加编码字符集为utf-8,新建文件可自动添加了
- Nav titleView 设置的两个方式
1.self.navigationItem.titleView = vv; 2.[self.navigationController.navigationBar addSubview:vv];
- SQL SERVER 2005中利用XML对字符串拆分的方法
1.常规方法(可运用于SQL SERVER 2000中) DECLARE @str varchar(1000) DECLARE @idoc int; DECLARE @doc xml;set @str ...
- 测试-一个unity的编译bug,初始化器
.net C#下测试: public class Class1 { public bool toggle1 = true; public bool toggle2; } 一个结构类Class1,对里面 ...
- springboot文件上传下载,转载的
Spring Boot入门——文件上传与下载 原文来自:https://www.cnblogs.com/studyDetail/articles/7003253.html 1.在pom.xml文件中添 ...
- redis命令_ZRANGE
ZRANGE key start stop [WITHSCORES] 返回有序集 key 中,指定区间内的成员. 其中成员的位置按 score 值递增(从小到大)来排序. 具有相同 score 值的成 ...
- ajax回调数据 Structs has detected an unhandled exception 问题
Structs has detected an unhandled exception 今天算倒霉了,用maven写的一个项目,竟然出现了以下低级的错误,在用ajax修改密码时,回调的数据竟然是以下的 ...