POJ 2771 Guardian of Decency
2018-06-17 21:17:40来源:未知 阅读 ()
Time Limit: 3000MS | Memory Limit: 65536K | |
Total Submissions: 6113 | Accepted: 2548 |
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
#include<iostream> #include<cstdio> #include<cstring> #include<cmath> using namespace std; const int MAXN=1001; int vis[MAXN]; int link[MAXN]; int map[MAXN][MAXN]; int N; bool dfs(int x) { for(int i=1;i<=N;i++) { if(map[x][i]&&!vis[i]) { vis[i]=1; if(!link[i]||dfs(link[i])) { link[i]=x; return 1; } } } return 0; } struct S { int tall; string a,b,c; }s[MAXN]; int main() { #ifdef WIN32 freopen("a.in","r",stdin); #else #endif int Test; scanf("%d",&Test); while(Test--) { memset(vis,0,sizeof(vis)); memset(link,0,sizeof(link)); memset(map,0,sizeof(map)); scanf("%d",&N); for(int i=1;i<=N;i++) cin>>s[i].tall>>s[i].a>>s[i].b>>s[i].c; for(int i=1;i<=N;i++) for(int j=1;j<=N;j++) if(i!=j&&s[i].a!=s[j].a&&s[i].b==s[j].b&&s[i].c!=s[j].c&&fabs(s[i].tall-s[j].tall)<=40 ) map[i][j]=1; int ans=0; for(int i=1;i<=N;i++) { memset(vis,0,sizeof(vis)); if(dfs(i)) ans++; } printf("%d\n",(N*2-ans)/2 ); } return 0; }
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
上一篇:后缀数组详解
下一篇:浅谈最大流的Dinic算法
- POJ-3278 2020-04-01
- Asteroids!_poj2225 2020-02-09
- poj-1753题题解思路 2020-01-26
- POJ1852 2019-11-11
- POJ2431 优先队列+贪心 - biaobiao88 2019-11-03
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash