#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. ueditor编辑器视频上传不能预览的问题

    ps:来源 https://blog.csdn.net/eadela/article/details/76264168 修改ueditor.all.js文件 ueditor.all.js,17769行 ...

  2. 修改oralce数据库用户名和密码

    首先以sys用户登录数据库 一.修改用户名 查到到所需修改用户名称的用户需要:select user#,name from user$;(例如查到有一个normal的用户对应的user#=61) 修改 ...

  3. jq+download+文件夹下载

    最近公司在做工程项目,实现文件夹下载. 网上找了很久,发现网上的代码都有相似的问题,不过最终还是让我找到了一个符合的项目. 工程: 进行项目文件夹下载功能分析,弄清楚文件夹下载的原理,提供的数据支持. ...

  4. C#重点内容之:委托(delegate)

    为了记忆方便,提取了重点. 委托类似于指针,可以理解为函数指针的升级版,这是理解委托最关键的地方. Action和Func 系统自带的两种委托: Action Func Action型委托要求委托的目 ...

  5. POJ3045--Cow Acrobats(theory proving)

    Farmer John's N (1 <= N <= 50,000) cows (numbered 1..N) are planning to run away and join the ...

  6. elasticsearch5环境搭建

    1.下载ElasticSearch https://www.elastic.co/cn/downloads/elasticsearch#ga-release 因为是windows版本,所以下载zip即 ...

  7. codeforces815A Karen and Game 2017-06-27 15:22 31人阅读 评论(0) 收藏

    C. Karen and Game time limit per test 2 seconds memory limit per test 512 megabytes input standard i ...

  8. 编写Shell脚本

    1.脚本的编写 Shell脚本本身是一个文本文件,这里编写一个简单的程序,在屏幕上显示一行helloworld! 脚本内容如下: #!/bin/bash #显示“Hello world!" ...

  9. 采用c3p0数据库连接池底层是jdbc的数据库的增删改查

    1.新建dbutils包,里面是JdbcUtils类: package cn.com.xxx.xxx.dbutil; import java.sql.Connection; import java.s ...

  10. POJ 2570 线段树

    Potted Flower Time Limit: 2000 MS Memory Limit: 65536 KB 64-bit integer IO format: %I64d , %I64u Jav ...