poj——2771 Guardian of Decency
| Time Limit: 3000MS | Memory Limit: 65536K | |
| Total Submissions: 5916 | Accepted: 2458 |
Description
- Their height differs by more than 40 cm.
- They are of the same sex.
- Their preferred music style is different.
- Their favourite sport is the same (they are likely to be fans of different teams and that would result in fighting).
So, for any two persons that he brings on the excursion, they must satisfy at least one of the requirements above. Help him find the maximum number of persons he can take, given their vital information.
Input
- an integer h giving the height in cm;
- a character 'F' for female or 'M' for male;
- a string describing the preferred music style;
- a string with the name of the favourite sport.
No string in the input will contain more than 100 characters, nor will any string contain any whitespace.
Output
Sample Input
2 4 35 M classicism programming 0 M baroque skiing 43 M baroque chess 30 F baroque soccer 8 27 M romance programming 194 F baroque programming 67 M baroque ping-pong 51 M classicism programming 80 M classicism Paintball 35 M baroque ping-pong 39 F romance ping-pong 110 M romance Paintball
Sample Output
3 7
Source
题意:现在有一个老师想带领他的学生出去郊游,但是他非常担心在郊游的过程中有些学生会发生恋爱关系,而他认为发生恋爱关系的可能性比较小的判断标准有以下四个,如果满足四个条件中的任何一个,即被他认为可能发生恋爱关系的可能性比较小:
1>两人身高的差距超过40cm;
2>两人性别相同;
3>两人所喜欢的音乐风格不同;
4>两人最喜爱的运动相同;
现在给出n个学生,并给出每个学生的信息(信息为:身高 性别 所喜欢的音乐风格 喜爱的运动),要求求解最大可以带出去郊游的学生数.
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define N 510
using namespace std;
char ch;
bool vis[N];
int t,n,x,ans,gnum,bnum,pre[N],map[N][N];
struct nn
{
int h;
];
];
}girl[N],boy[N];
int read()
{
,f=;char ch=getchar();
; ch=getchar();}
+ch-'; ch=getchar();}
return x*f;
}
void add_edge()
{
;i<=bnum;i++)
;j<=gnum;j++)
)
map[i][j]=;
}
int find(int x)
{
;i<=gnum;i++)
if(!vis[i]&&map[x][i])
{
vis[i]=true;
||find(pre[i]))
{
pre[i]=x;
;
}
}
;
}
int main()
{
t=read();
while(t--)
{
ans=;bnum=,gnum=;
memset(boy,,sizeof(boy));
memset(girl,,sizeof(girl));
memset(pre,,sizeof(pre));
memset(map,,sizeof(map));
n=read();
;i<=n;i++)
{
x=read(); scanf("%c",&ch);
if(ch=='F')
{
girl[++gnum].h=x;
cin>>girl[gnum].fm;
cin>>girl[gnum].fs;
}
else
{
boy[++bnum].h=x;
cin>>boy[bnum].fm;
cin>>boy[bnum].fs;
}
}
add_edge();
;i<=bnum;i++)
{
memset(vis,,sizeof(vis));
if(find(i)) ans++;
}
printf("%d\n",n-ans);
}
;
}
poj——2771 Guardian of Decency的更多相关文章
- POJ 2771 Guardian of Decency 【最大独立集】
传送门:http://poj.org/problem?id=2771 Guardian of Decency Time Limit: 3000MS Memory Limit: 65536K Tot ...
- POJ 2771 Guardian of Decency (二分图最大点独立集)
Guardian of Decency Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 6133 Accepted: 25 ...
- POJ 2771 Guardian of Decency(最大独立集数=顶点数-最大匹配数)
题目链接: http://poj.org/problem?id=2771 Description Frank N. Stein is a very conservative high-school t ...
- POJ 2771 Guardian of Decency
http://poj.org/problem?id=2771 题意: 一个老师想带几个同学出去,但是他怕他们会谈恋爱,所以带出去的同学两两之间必须满足如下条件之一: ①身高差大于40 ②同性 ③喜欢 ...
- poj 2771 Guardian of Decency 解题报告
题目链接:http://poj.org/problem?id=2771 题目意思:有一个保守的老师要带他的学生来一次短途旅行,但是他又害怕有些人会变成情侣关系,于是就想出了一个方法: 1.身高差距 ...
- POJ 2771 Guardian of Decency(求最大点独立集)
该题反过来想:将所有可能发生恋爱关系的男女配对,那么可以带出去的人数应该等于这个二分图的最大独立集 先要做一下预处理,把不符合要求的双方先求出来, company[i][j]表示i.j四个标准都不符合 ...
- UVA 12083 POJ 2771 Guardian of Decency
/* http://acm.hust.edu.cn/vjudge/contest/view.action?cid=71805#problem/C */ 性质: [1]二分图最大点独立数=顶点数-二分图 ...
- poj 2771 Guardian of Decency(最大独立数)
题意:人与人之间满足4个条件之一即不能成为一对(也就说这4个条件都不满足才能成为一对),求可能的最多的单身人数. 思路:把男女分为两部分,接下来就是二分图的匹配问题.把能成为一对的之间连边,然后求出最 ...
- POJ——T2271 Guardian of Decency
http://poj.org/problem?id=2771 Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 5932 A ...
随机推荐
- 不能说的hidden
不能说的hidden 时光跑跑...路在脚下...晨光依在...----Vashon 1.所谓"时尚",本质上就是自己看不见自己的样子.好比我们在地球上,却感觉不到地球在动. 2. ...
- DECLARE - 定义一个游标
SYNOPSIS DECLARE name [ BINARY ] [ INSENSITIVE ] [ [ NO ] SCROLL ] CURSOR [ { WITH | WITHOUT } HOLD ...
- JavaScript设计模式基础之面向对象的JavaScript(一)
动态语言类型与鸭子类型 此内容取自JavaScript设计模式与开发实践一书 编程语言按照数据类型大体可以分为2类,一类就是静态类型语言,另一类则是动态类型语言 静态类型语言也可以称之为编译语言,而动 ...
- hdu5126 stars
题目描述 题解: 和二维的比起来差不多. 但是这是四维偏序. 所以搞一下CDQ套CDQ. CDQ是维度a已经有序,按维度b排序,然后将维度c存入一维数据结构. 所以我们在第一层CDQ中分治处理,将合法 ...
- 14. PARAMETERS
14. PARAMETERS PARAMETERS表提供有关存储例程(存储过程和存储函数)的参数以及存储函数的返回值的信息. PARAMETERS表不包含内置SQL函数或用户定义函数(UDF). 参数 ...
- MongoDB中导入数据命令的使用(mongoimport)
MongoDB中导入数据命令的使用(mongoimport) 制作人:全心全意 语法: mongoimport <options> <file> 介绍: 该命令可以将CSV,T ...
- iptables:ipset批量管理ip
1.安装 安装: yum -y install ipset \apt-get -y install ipset 2.创建一个ipset ipset create whitelist hash:net ...
- Ubuntu配置SSH服务器
SSH 为 Secure Shell 的缩写,由 IETF 的网络小组(Network Working Group)所制定:SSH 为建立在应用层和传输层基础上的安全协议.SSH 是目前较可靠,专为远 ...
- Nginx Location和Rewrite总结
Nginx 版本:nginx/1.10.3 (Ubuntu) Location 部分: 第一步:创建Nginx 虚拟主机 Nginx 安装成功安装并且可以运行之后,在 /etc/nginx 目录下创建 ...
- 杭电 1241 Oil Deposits (很好的dfs)
Description The GeoSurvComp geologic survey company is responsible for detecting underground oil dep ...