博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdu3829——Cat VS Dog(最大独立集)
阅读量:2343 次
发布时间:2019-05-10

本文共 1497 字,大约阅读时间需要 4 分钟。

Problem Description

The zoo have N cats and M dogs, today there are P children visiting the zoo, each child has a like-animal and a dislike-animal, if the child’s like-animal is a cat, then his/hers dislike-animal must be a dog, and vice versa.
Now the zoo administrator is removing some animals, if one child’s like-animal is not removed and his/hers dislike-animal is removed, he/she will be happy. So the administrator wants to know which animals he should remove to make maximum number of happy children.

Input

The input file contains multiple test cases, for each case, the first line contains three integers N <= 100, M <= 100 and P <= 500.
Next P lines, each line contains a child’s like-animal and dislike-animal, C for cat and D for dog. (See sample for details)

Output

For each case, output a single integer: the maximum number of happy children.

Sample Input

1 1 2
C1 D1
D1 C1

1 2 4

C1 D1
C1 D1
C1 D2
D2 C1

Sample Output

1
3

Hint

Case 2: Remove D1 and D2, that makes child 1, 2, 3 happy.

对小孩拆点,能建边的条件是两个小孩喜欢的动物和不喜欢的正好矛盾,说明这两个小孩需要作出取舍,接下来最大幸福度就是作出最大限度不用作出取舍的小孩的幸福度,其实就是最大独立集

当然以上都是我口胡的

#include 
#include
#include
#include
#include
#include
#include
#include
//#include
#include
#define INF 0x3f3f3f3f#define MAXN 1505#define Mod 10001using namespace std;bool vis[MAXN];int pre[MAXN],n; //匹配路径;vector
map[MAXN];string like[MAXN],dislike[MAXN];int find(int cur){ for(int i=0; i
>a>>b; like[i]=a; dislike[i]=b; } for(int i=0; i

转载地址:http://ovcvb.baihongyu.com/

你可能感兴趣的文章
java根据文件流判断文件类型(后缀名)
查看>>
js常用操作事件
查看>>
linux 安装mysql
查看>>
利用SQL语句查询数据库中所有表
查看>>
ActiveMQ 安装
查看>>
java可变参数
查看>>
spring 简述
查看>>
HttpClient-03Http状态管理
查看>>
spring cloud 启动报错-must be declared as an @AliasFor [serviceId], not [name].
查看>>
常用软件下载地址
查看>>
修改spring boot 启动logo
查看>>
spring boot-启动及配置文件
查看>>
HttpsURLConnection 安全传输(HTTPS--Secure Hypertext Transfer Protocol-安全超文本传输协议)...
查看>>
ASP.NET跨页面传值的技巧
查看>>
ASP.NET页面之间传递值解析
查看>>
我要学ASP.NET MVC 3.0(八): MVC 3.0 传递和保存你的Model
查看>>
我要学ASP.NET MVC 3.0(九): MVC 3.0 验证你的Model
查看>>
我要学ASP.NET MVC 3.0(十): MVC 3.0 使用 Forms身份验证
查看>>
我要学ASP.NET MVC 3.0(十一): MVC 3.0 使用筛选器
查看>>
ASP.NET MVC3、Pager 分页
查看>>