Guardian of Decency UVALive - 3415(最大独立集板题)
老师在选择一些学生做活动时,为避免学生发生暧昧关系,就提出了四个要求。在他眼中,只要任意两个人符合这四个要求之一,就不可能发生暧昧。现在给出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(最大独立集板题)的更多相关文章
- Guardian of Decency UVALive - 3415 最大独立集=结点数-最大匹配数 老师带大学生旅游
/** 题目:Guardian of Decency UVALive - 3415 最大独立集=结点数-最大匹配数 老师带大学生旅游 链接:https://vjudge.net/problem/UVA ...
- 训练指南 UVALive - 3415(最大点独立集)
layout: post title: 训练指南 UVALive - 3415(最大点独立集) author: "luowentaoaa" catalog: true mathja ...
- POJ 2771 Guardian of Decency 【最大独立集】
传送门:http://poj.org/problem?id=2771 Guardian of Decency Time Limit: 3000MS Memory Limit: 65536K Tot ...
- Guardian of Decency(二分图)
Guardian of Decency Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submi ...
- 【凸包板题】Gym - 101484E E. Double Fence
http://codeforces.com/gym/101484/problem/E 题解 凸包板题 #define _CRT_SECURE_NO_WARNINGS #include<cmath ...
- Oil Skimming HDU - 4185(匹配板题)
Oil Skimming Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tota ...
- UVALive.3708 Graveyard (思维题)
UVALive.3708 Graveyard (思维题) 题意分析 这标题真悲伤,墓地. 在周长为1e4的圆周上等距分布着n个雕塑,现在要加入进来m个雕塑,最终还要使得这n+m个雕塑等距,那么原来的n ...
- POJ 2771 Guardian of Decency (二分图最大点独立集)
Guardian of Decency Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 6133 Accepted: 25 ...
- uva 12083 Guardian of Decency (二分图匹配)
uva 12083 Guardian of Decency Description Frank N. Stein is a very conservative high-school teacher. ...
随机推荐
- 试用一下markdown
1 2 3 4 5 6 Blog
- NLP的12条精髓
NLP是神经语言程序学 (Neuro-Linguistic Programming) 的英文缩写.一.没有两个人是一样的 No two persons are the same. 1.没有两个人的人生 ...
- java 多路分发
1.概念 一个函数处理多种类型,其实和多态差不多. 但是要处理两种或者多种类型的数据时,就需要判断每种类型以及每种类型所对应的处理.(PS:我只是在走别人的老路,网上一搜这种概念,博客一大堆,我不知道 ...
- xshell连接虚拟机linux系统失败问题
问题:在xshell新建对话弹出的对话框中输入ip地址后,确定并没有弹出输入用户名和密码对话框 直接显示连接失败 Could not connect to ): Connection failed. ...
- 学习HTML 第一节.小试牛刀
此贴并非教学,主要是自学笔记,所述内容只是些许个人学习心得的记录和备查积累,难以保证观点正确,也不一定能坚持完成. 如不幸到访,可能耽误您的时间,也难及时回复,贴主先此致歉.如偶有所得,相逢有缘,幸甚 ...
- 【视频编解码·学习笔记】4. H.264的码流封装格式 & 提取NAL有效数据
一.码流封装格式简单介绍: H.264的语法元素进行编码后,生成的输出数据都封装为NAL Unit进行传递,多个NAL Unit的数据组合在一起形成总的输出码流.对于不同的应用场景,NAL规定了一种通 ...
- Halcon学习网
重码网是一个在线机器视觉学习网站,推出了Halcon,Visionpro机器视觉学习视频教程,视频内容通俗易懂,没有编程基础的同学,照着视频练习,也同样可以学会. 学机器视觉,拿高薪,成就技术大拿.重 ...
- Paper Reading - Show and Tell: A Neural Image Caption Generator ( CVPR 2015 )
Link of the Paper: https://arxiv.org/abs/1411.4555 Main Points: A generative model ( NIC, GoogLeNet ...
- PHP中的变量名,函数名,类名是区分大小写的吗
在PHP中,自定义的函数名,类名,以及内置的函数,关键字是不区分大小写的,比如: class,Class,CLASS,while,While,ECHO,echo,NULL,Null 都是一样的. 但是 ...
- 王者荣耀交流协会 — Alpha阶段中间产物
1. 版本控制 Coding :https://git.coding.net/SuperCodingChao/PSPDaily.git 2. 软件功能说明书 软件功能说明书发布在小组成员袁玥同学的博客 ...