老师在选择一些学生做活动时,为避免学生发生暧昧关系,就提出了四个要求。在他眼中,只要任意两个人符合这四个要求之一,就不可能发生暧昧。现在给出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. Ceph学习之路(二)之Ceph的工作原理及流程

    一.RADOS的对象寻址 Ceph 存储集群从 Ceph 客户端接收数据——不管是来自 Ceph 块设备. Ceph 对象存储. Ceph 文件系统.还是基于 librados 的自定义实现——并存储 ...

  2. 杂谈001:晨曦Dawn的重新连接

    ------------吾亦无他,唯手熟尔,谦卑若愚,好学若饥------------- 摘要: 我是晨曦,好久没有关注过我的博客了,整天都在乱糟糟的忙,叙述一下我消失的这段时间,然后我准备做几个专题 ...

  3. QML和JS引擎的关系以及调用c++函数的原理

    首先推荐几篇博客 1.深入解析QML引擎, 第1部分:QML文件加载 https://www.cnblogs.com/wzxNote/p/10569535.html 2.深入解析QML引擎, 第2部分 ...

  4. linux系统CPU内存磁盘监控发送邮件脚本

    #!/bin/bashexport PATHexport LANG=zh_CN.UTF-8###top之后输入数字1,可以查看每颗CPU的情况.###先配置好mailx邮箱账号密码:#cat>/ ...

  5. Linux 安装FastDFS<单机版>(使用Mac远程访问)

    阅读本文需要先阅读安装FastDFS<准备> 一 编译环境 yum install gcc-c++ yum -y install libevent yum install -y pcre ...

  6. UGUI简易摇杆

    实现 直接使用系统自带圆形控件图标 编写脚本, 实现UGUI拖拽事件 将多拽范围限定于给定半径和圆心的圆内 计算出等同于Input.GetAxis()的值,直接控制被控制物体 代码 using Sys ...

  7. docker简单使用+django+uwsgi+nginx项目部署

    使用docker 搭建 centos7 环境: 主机环境:windows 10专业版 一.安装docker Hub.docker.com官网下载 docker for windows 安装完成后,任务 ...

  8. Git + Gerrit 操作备忘

    Git review 作用 可以用来提交代码审核到Gerrit 安装 使用pip 安装 git-review 插件,执行 sudo -H pip install git-review 使用示例 可以参 ...

  9. linux-sftp-指定端口号登录远程主机

    sftp -oPort=60001 root@192.168.0.254 -o选项来指定端口号 -oPort=远程端口号

  10. txt文件存储问题

    一.实际大小与占用空间不一致: 1.占用空间和磁盘有关,一般磁盘存储最小大小为4kb(4096字节). 2.当txt文件中仅有1个数字‘5’的时候,大小显示为1个字节(属性看,列表详细不精确),占用空 ...