#include <iostream>
#include <string>
#define MAXN 505 using namespace std; int _m[MAXN][MAXN];
int match[MAXN];
bool ck[MAXN]; struct node
{
int _high;
char M_F;
string _music;
string _habit;
};
int hungary(int a,int b);
node _node[MAXN]; int main()
{
// freopen("acm.acm","r",stdin);
int test;
int i;
int j;
int n;
cin>>test;
while(test --)
{
cin>>n;
for(i = ; i < n; ++ i)
{
cin>>_node[i]._high;
cin>>_node[i].M_F;
cin>>_node[i]._music;
cin>>_node[i]._habit;
}
memset(_m,,sizeof(_m));
for(i = ; i < n; ++ i)
{
for(j = ; j < i; ++ j)
{
if(abs(_node[i]._high-_node[j]._high) <= && _node[i].M_F != _node[j].M_F && _node[i]._music == _node[j]._music && _node[i]._habit != _node[j]._habit)
{
_m[i][j] = ;
_m[j][i] = ;
}
}
}
cout<<n-hungary(n,n)/<<endl;
}
} /////////////////////////////////////////////////////////////////////////
//hungary算法,自己写的模板!
/////////////////////////////////////////////////////////////////////////
bool search(int a,int b,int x)
{
int i;
int t;
for ( i = ; i < b ; i++)
if (_m[x][i] && ! ck[i])
{
ck[i] = true;
t = match[i];
match[i] = x;
if (t == - || search(a,b,t))
return true;
match[i] = t;
}
return false;
} int hungary(int a,int b)
{
memset(match,-,sizeof(match));
int max_match = ;
int i;
for ( i = ; i < a ; i++)
{
memset(ck,false,sizeof(ck));
if (search(a,b,i))
max_match++;
}
return max_match;
}

POJ 2771的更多相关文章

  1. poj——2771 Guardian of Decency

    poj——2771    Guardian of Decency Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 5916   ...

  2. Poj(2771),最大独立集

    题目链接:http://poj.org/problem?id=2771 Guardian of Decency Time Limit: 3000MS   Memory Limit: 65536K To ...

  3. POJ 2771 Guardian of Decency(最大独立集数=顶点数-最大匹配数)

    题目链接: http://poj.org/problem?id=2771 Description Frank N. Stein is a very conservative high-school t ...

  4. POJ 2771 Guardian of Decency

    http://poj.org/problem?id=2771 题意: 一个老师想带几个同学出去,但是他怕他们会谈恋爱,所以带出去的同学两两之间必须满足如下条件之一: ①身高差大于40  ②同性 ③喜欢 ...

  5. POJ 2771 Guardian of Decency 【最大独立集】

    传送门:http://poj.org/problem?id=2771 Guardian of Decency Time Limit: 3000MS   Memory Limit: 65536K Tot ...

  6. poj 2771 Guardian of Decency 解题报告

    题目链接:http://poj.org/problem?id=2771 题目意思:有一个保守的老师要带他的学生来一次短途旅行,但是他又害怕有些人会变成情侣关系,于是就想出了一个方法: 1.身高差距   ...

  7. POJ 2771 二分图(最大独立集)

    Guardian of Decency Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 5244   Accepted: 21 ...

  8. POJ 2771 Guardian of Decency(求最大点独立集)

    该题反过来想:将所有可能发生恋爱关系的男女配对,那么可以带出去的人数应该等于这个二分图的最大独立集 先要做一下预处理,把不符合要求的双方先求出来, company[i][j]表示i.j四个标准都不符合 ...

  9. poj 2771 最大独立集

    这道题又无耻的抄袭了别人的代码. 刚开始以为是最大匹配,把条件不相符的人连一起,然后求最大匹配,感觉麻烦,然后看了别人的解题报告,是把相符的人连一起,然后减去,其实就是最大独立集. 最大独立集=|G| ...

  10. UVA 12083 POJ 2771 Guardian of Decency

    /* http://acm.hust.edu.cn/vjudge/contest/view.action?cid=71805#problem/C */ 性质: [1]二分图最大点独立数=顶点数-二分图 ...

随机推荐

  1. AngularJs ng-repeat用法二$parent.$index

    我们在开发时时常会出现repeat嵌套使用的情况,此时会想获取父级repeat数组的下标可使用$parent.$index

  2. vue+大文件分片上传

    最近公司在使用vue做工程项目,实现大文件分片上传. 网上找了一天,发现网上很多代码都存在很多问题,最后终于找到了一个符合要求的项目. 工程如下: 对项目的大文件上传功能做出分析,怎么实现大文件分片上 ...

  3. 整理mianshi2

    1.性能优化相关https://www.cnblogs.com/cr330326/p/8011523.html 2.CountDownLatchjava共享锁实现原理及CountDownLatch解析 ...

  4. CentOS和Ubuntu哪个好?

    CentOS(Community ENTerprise Operating System)是Linux发行版之一,它是来自于Red Hat Enterprise Linux依照开放源代码规定释出的源代 ...

  5. 去除html页面中GET《 http://localhost:8080/favicon.ico 404 (Not Found)》

    html5页面中经常会遇见以下问题,总是看着碍眼,那么怎么解决呢? GET http://localhost:8080/favicon.ico 404 (Not Found) 解决的方法: <l ...

  6. web-day11

    第11章WEB11-Cookie&Session篇 今日任务 显示用户的上次访问时间 登录系统以后显示商品浏览记录 购买商品将商品添加到购物车 系统登录的验证码的校验 教学导航 教学目标 了解 ...

  7. restfull和传统http的区别

    摘自 https://bbs.csdn.net/topics/390716580 restfull是一种风格,不是规范,也不是所谓的封装,他只是将http协议用的更彻底了,我们在普通的开发中,虽然说是 ...

  8. Android多线程操作sqlite(Sqlite解决database locked问题)

    参考http://blog.csdn.net/sdsxleon/article/details/18259973  很好 https://github.com/2point0/Android-Data ...

  9. Codeforces821A Okabe and Future Gadget Laboratory 2017-06-28 14:55 80人阅读 评论(0) 收藏

    A. Okabe and Future Gadget Laboratory time limit per test 2 seconds memory limit per test 256 megaby ...

  10. js-实现双色球功能

    <!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8&qu ...