老师在选择一些学生做活动时,为避免学生发生暧昧关系,就提出了四个要求。在他眼中,只要任意两个人符合这四个要求之一,就不可能发生暧昧。现在给出n个学生关于这四个要求的信息,求老师可以挑选出的最大学生数量。

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#define rap(i, a, n) for(int i=a; i<=n; i++)
#define MOD 2018
#define LL long long
#define ULL unsigned long long
#define Pair pair<int, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define _ ios_base::sync_with_stdio(0),cin.tie(0)
//freopen("1.txt", "r", stdin);
using namespace std;
const int maxn = , INF = 0x7fffffff;
int n;
int line[maxn][maxn], girl[maxn], used[maxn]; struct node
{
int h;
char s;
string music, sports;
}Node[maxn]; bool find(int x)
{
for(int i=; i<=n; i++)
{
if(line[x][i] && !used[i])
{
used[i] = ;
if(!girl[i] || find(girl[i]))
{
girl[i] = x;
return ;
}
}
}
return ;
} int main()
{
int T;
scanf("%d", &T);
while(T--)
{
int res = ;
mem(girl, );
mem(line, );
scanf("%d", &n);
rap(i, , n)
{
cin>> Node[i].h >> Node[i].s >> Node[i].music >> Node[i].sports;
}
rap(i, , n)
rap(j, i+, n)
{
if(abs(Node[i].h - Node[j].h) <= && Node[i].s != Node[j].s && Node[i].music == Node[j].music && Node[i].sports != Node[j].sports)
{
line[i][j] = line[j][i] = ;
}
}
rap(i, , n)
{
mem(used, );
if(find(i))
res++;
} printf("%d\n", n - res/);
} return ;
}

Guardian of Decency UVALive - 3415(最大独立集板题)的更多相关文章

  1. Guardian of Decency UVALive - 3415 最大独立集=结点数-最大匹配数 老师带大学生旅游

    /** 题目:Guardian of Decency UVALive - 3415 最大独立集=结点数-最大匹配数 老师带大学生旅游 链接:https://vjudge.net/problem/UVA ...

  2. 训练指南 UVALive - 3415(最大点独立集)

    layout: post title: 训练指南 UVALive - 3415(最大点独立集) author: "luowentaoaa" catalog: true mathja ...

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

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

  4. Guardian of Decency(二分图)

    Guardian of Decency Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submi ...

  5. 【凸包板题】Gym - 101484E E. Double Fence

    http://codeforces.com/gym/101484/problem/E 题解 凸包板题 #define _CRT_SECURE_NO_WARNINGS #include<cmath ...

  6. Oil Skimming HDU - 4185(匹配板题)

    Oil Skimming Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

  7. UVALive.3708 Graveyard (思维题)

    UVALive.3708 Graveyard (思维题) 题意分析 这标题真悲伤,墓地. 在周长为1e4的圆周上等距分布着n个雕塑,现在要加入进来m个雕塑,最终还要使得这n+m个雕塑等距,那么原来的n ...

  8. POJ 2771 Guardian of Decency (二分图最大点独立集)

    Guardian of Decency Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 6133   Accepted: 25 ...

  9. uva 12083 Guardian of Decency (二分图匹配)

    uva 12083 Guardian of Decency Description Frank N. Stein is a very conservative high-school teacher. ...

随机推荐

  1. jenkins自动打包部署linux

    需要用到2个插件. git parameter:用于参数化构建时选择分支. Publish Over SSH:用于上传jar包和操作tomcat 1.先在系统设置添加要连接的linux服务器,使用用户 ...

  2. 用php做个简单的日历

    存档: index.php <html> <head> <title>日历</title> <style> table{border:1px ...

  3. tomcat7以上的版本,400BadRequest

    出现此原因的解决办法其一,详情可见: https://www.cnblogs.com/dygrkf/p/9088370.html. 另一种解决方法,就是把url中不允许出现的字符编码,后台接收时再解码 ...

  4. JS 中屏幕、浏览器和文档的高度、宽度和距离

    1.各种对象 window.screen - 屏幕,window - 窗口,document.documentElement & document.body.parentNode - 文档,d ...

  5. 面向 Unity* 软件和虚拟现实的优化:运行时生成内容

    优化游戏以实现高性能一直是游戏开发过程中的一个重要因素.虽然开发人员一直尝试将硬件推向极致,但当移动游戏成为主流时,优化技术变得尤为突出.Unity* 软件.Unreal* 等常见引擎最初都是面向 P ...

  6. python学习笔记01 --------------hello world 与变量。

    1.第一个程序: print('hello world') 输出结果: hello world 2.变量 2.1 变量的作用: 把程序运算的中间结果临时存到内存里,以备后面的代码继续调用. 2.2 变 ...

  7. Nginx之一:Nginx的编译安装

    一.Nginx简介 官方网址:http://nginx.org/ Nginx是由1994年毕业于俄罗斯国立莫斯科鲍曼科技大学的同学为俄罗斯rambler.ru公司开发的,开发工作最早从2002年开始, ...

  8. 第六次ScrumMeeting博客

    第六次ScrumMeeting博客 本次会议于10月31日(二)22时整在3公寓725房间召开,持续15分钟. 与会人员:刘畅.辛德泰.窦鑫泽.张安澜.赵奕.方科栋. 除了汇报任务外,窦鑫泽同学还就前 ...

  9. JS加密库

    作者声明:本博客中所写的文章,都是博主自学过程的笔记,参考了很多的学习资料,学习资料和笔记会注明出处,所有的内容都以交流学习为主.有不正确的地方,欢迎批评指正 本文主要是参考aicoder马伦老师的博 ...

  10. linux计划任务 学习笔记

    原文链接: http://www.tsingfeng.com/?tag=cronjob 本文说的计划任务是指linux的Cronjob.语法 下面是个简单的计划任务: 10 * * * * /usr/ ...