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 ...
随机推荐
- 全排列算法 --javascript 实现
var Ann = function a(arr){ if(arr.length == 1){return arr;} var rr = new Array(); for(var i = 0; i&l ...
- Spring MVC 单元测试异常 Caused by: org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file
Sping 3.2.8.RELEASE + sping mvc + JDK 1.8运行异常. java.lang.IllegalStateException: Failed to load Appli ...
- Java 连接 Oracle 数据库
首先要导入ojdbc6.jar 包(放在lib文件夹) 然后需要在数据库建一个student表进行测试: 连接及测试代码: import java.security.interfaces.RSAKey ...
- MongoDB Query 判断为空 取值为空的时间
if (!string.IsNullOrEmpty(STATES)) { DateTime? dtnull = null; //Return if (STATES == "Return&qu ...
- win8安装Visual C++ 2015 build tools闪退解决办法
win8安装Visual C++ 2015 build tools闪退解决办法 安装Visual Studio 2015闪退问题也同样应用此解决办法. 1.控制面板——添加删除程序——启动关闭wind ...
- Atitit.检测文本文件的编码 自动获取文件的中文编码
Atitit.检测文本文件的编码 自动获取文件的中文编码 1 不能使用load来检测编码..1 2 使用convert来检测编码1 3 程序检测文本编码2 3.1 根据utf bom头2 3.2 检测 ...
- 王立平-- Swift
Swift是供iOS和OS X应用编程的新编程语言,基于C和Objective-C.而却没有C的一些兼容约束.Swift採用了安全的编程模式和加入现代的功能来是的编程更加简单.灵活和有趣. 界面则基于 ...
- Aspose.Cells 导出指定格式项目(金额、数字、文本)
Aspose.Cells为开发人员提供了许多内嵌的数字和日期格式,开发人员可以通过Style对象的Number属性调用这些内嵌格式,下面是Aspose.Cells提供的显示格式:Value Type ...
- spring aop切面编程实现操作日志步骤
1.在spring-mvc.xml配置文件中打开切面开关: <aop:aspectj-autoproxy proxy-target-class="true"/> 注意: ...
- 让一个 csproj 项目指定多个开发框架[转]
原贴:https://walterlv.gitee.io/post/configure-projects-to-target-multiple-platforms.html 可移植类库.共享项目..N ...