老师在选择一些学生做活动时,为避免学生发生暧昧关系,就提出了四个要求。在他眼中,只要任意两个人符合这四个要求之一,就不可能发生暧昧。现在给出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. poj 2079(旋转卡壳求解凸包内最大三角形面积)

    Triangle Time Limit: 3000MS   Memory Limit: 30000K Total Submissions: 9060   Accepted: 2698 Descript ...

  2. 【JUC源码解析】ConcurrentHashMap

    简介 支持并发的哈希表.其中包括红黑树,扩容,分槽计数等知识点. 源码分析 常量 private static final int MAXIMUM_CAPACITY = 1 << 30; ...

  3. 搜索引擎ElasticSearch系列(三): ElasticSearch2.4.4 bigdesk插件安装

    一:ElasticSearch bigdesk插件简介 bigdesk是elasticsearch的一个集群监控工具,可以通过它来查看es集群的各种状态,如:cpu.内存使用情况,索引数据.搜索情况, ...

  4. hdu2187悼念512汶川大地震遇难同胞——老人是真饿了(贪心 简单题)

    传送门 简单题 #include<bits/stdc++.h> using namespace std; struct node { double dan,weight; }a[]; bo ...

  5. gitlab runner 填坑记

    一.Gitlab Runner  CI/CD 错误: Couldn't connect to Docker daemon at http+docker://localhost - is it runn ...

  6. JMeter与WireShark

    最近在学习JMeter,刚学了一点皮毛,就掉入了WireShark的坑,我发现在学习的道路上就是不断的给自己挖坑,之前在学习LoadRunner的道路上,遇到的坑更大,就单纯的安装LR就耗费了两个星期 ...

  7. Web自动化常用方法封装(不定时更新)

    /** * JScript实现鼠标悬停 */public void mouseHoverJScript(By by,WebElement HoverElement) { // TODO Auto-ge ...

  8. git remote add origin错误

    如果输入$ Git remote add origin git@github.com:djqiang(github帐号名)/gitdemo(项目名).git 提示出错信息:fatal: remote ...

  9. JUC——JUC开发简介(一)

    前言 JUC是Java5.0开始提供的一组专门实现多线程并发处理的开发框架,利用JUC开发架构可以有效的解决实际线程项目开发之中出现的死锁.阻塞.资源访问与公平机制. 此笔记主要记录java.util ...

  10. 如何使用Win+R快捷键打开自定义程序

    鉴于大家对于提高效率这块有争议,更改了下标题. 大家平时一定都使用过Win+R运行快捷键, 在运行里可以快捷的打开一些系统软件,比如说输入mstsc是打开远程连接,输入explorer是打开文件管理器 ...