poj —— 1274 The Perfect Stall
| Time Limit: 1000MS | Memory Limit: 10000K | |
| Total Submissions: 26274 | Accepted: 11672 |
Description
Given the preferences of the cows, compute the maximum number of milk-producing assignments of cows to stalls that is possible.
Input
Output
Sample Input
5 5 2 2 5 3 2 3 4 2 1 5 3 1 2 5 1 2
Sample Output
4
Source
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define N 505
using namespace std;
bool vis[N];
int n,m,k,x,ans,girl[N],map[N][N];
int read()
{
,f=; char ch=getchar();
; ch=getchar();}
+ch-'; ch=getchar();}
return x*f;
}
int find(int x)
{
;i<=m;i++)
{
if(!vis[i]&&map[x][i])
{
vis[i]=true;
||find(girl[i])){girl[i]=x; ;}
}
}
;
}
int main()
{
while(scanf("%d%d",&n,&m)!=EOF)
{
ans=;
memset(map,,sizeof(map));
memset(girl,-,sizeof(girl));
;i<=n;i++)
{
k=read();
;
}
;i<=n;i++)
{
memset(vis,,sizeof(vis));
if(find(i)) ans++;
}
printf("%d\n",ans);
}
;
}
poj —— 1274 The Perfect Stall的更多相关文章
- Luogu 1894 [USACO4.2]完美的牛栏The Perfect Stall / POJ 1274 The Perfect Stall(二分图最大匹配)
Luogu 1894 [USACO4.2]完美的牛栏The Perfect Stall / POJ 1274 The Perfect Stall(二分图最大匹配) Description 农夫约翰上个 ...
- poj——1274 The Perfect Stall
poj——1274 The Perfect Stall Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 25709 A ...
- POJ 1274 The Perfect Stall || POJ 1469 COURSES(zoj 1140)二分图匹配
两题二分图匹配的题: 1.一个农民有n头牛和m个畜栏,对于每个畜栏,每头牛有不同喜好,有的想去,有的不想,对于给定的喜好表,你需要求出最大可以满足多少头牛的需求. 2.给你学生数和课程数,以及学生上的 ...
- POJ 1274 The Perfect Stall、HDU 2063 过山车(最大流做二分匹配)
The Perfect Stall Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 24081 Accepted: 106 ...
- poj 1274 The Perfect Stall【匈牙利算法模板题】
The Perfect Stall Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 20874 Accepted: 942 ...
- poj 1274 The Perfect Stall (二分匹配)
The Perfect Stall Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 17768 Accepted: 810 ...
- poj 1274 The Perfect Stall 解题报告
题目链接:http://poj.org/problem?id=1274 题目意思:有 n 头牛,m个stall,每头牛有它钟爱的一些stall,也就是几头牛有可能会钟爱同一个stall,问牛与 sta ...
- [题解]poj 1274 The Perfect Stall(网络流)
二分匹配传送门[here] 原题传送门[here] 题意大概说一下,就是有N头牛和M个牛棚,每头牛愿意住在一些牛棚,求最大能够满足多少头牛的要求. 很明显就是一道裸裸的二分图最大匹配,但是为了练练网络 ...
- [POJ] 1274 The Perfect Stall(二分图最大匹配)
题目地址:http://poj.org/problem?id=1274 把每个奶牛ci向它喜欢的畜栏vi连边建图.那么求最大安排数就变成求二分图最大匹配数. #include<cstdio> ...
随机推荐
- Windows10系统切换JDK版本(前提是装了多个版本的JDK)
由于是直接截屏,等我回过头来整理的时候忘记了文章原来的出处, 如作者本人看到,如有侵权,请联系删除!
- Scala基础篇-04 try表达式
1.try表达式 定义 try{} catch{} finally{} //例子 try{ Integer.parseInt("dog") }catch { }finally { ...
- win7+idea+maven搭建spark源码阅读环境
1.参考. 利用IDEA工具编译Spark源码(1.60~2.20) https://blog.csdn.net/He11o_Liu/article/details/78739699 Maven编译打 ...
- Objective - c Chapter 1 -2 Hello world
Objective - c Chapter 1 Hello world 1.1 1.2.On the Welcome screen, click "Create a new Xcode ...
- rar在linux下安装更新
1.下载:根据主机系统下载合适的版本,当前64为centos系统演示下载: wget http://www.rarlab.com/rar/rarlinux-x64-5.3.0.tar.gz 2.解压安 ...
- select在数据库中有两种含义
select在数据库中有两种意思 (1)是赋值的意思(2)是输出,打印的意思我想你问的大概是赋值吧print和 select在数据库中都有打印输出的意思 用法是:select @aa=select* ...
- python根据日期返回星期
import time #定义:timedate为时间戳def formattime(timedate,s="%Y-%m-%d %H:%M:%S"): return ...
- 执行jar包报错:udfFull.jar中没有主清单属性
在windows系统的cmd命令行窗口中执行: java -jar udfFull.jar {"movie":"1287","rate":& ...
- Vue-cli 3.0自定义脚手架
一.进入项目地址 https://github.com/vuejs/vue-cli ,选择 docs目录查看具体安装流程. 中文文档:https://cli.vuejs.org/zh 可以看到我电脑上 ...
- 零基础入门学习Python(11)--列表:一个打了激素的数组(2)
前言 上节课我们介绍一个打了激素的数组,叫做列表.列表我们比作一个大仓库,你所能够具现化的东西,都可以往里面扔,它包罗万象.另外还介绍了三个往列表添加元素的方法,分别是: append(),exten ...