Girls and Boys(最大独立集=节点数-最大匹配数)

青龙脚本(高佣联盟,附脚本)(已废) 青龙脚本(高佣联盟,附脚本) 阅读详情

Link:http://acm.hdu.edu.cn/showproblem.php?pid=1068

Girls and Boys

Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 7756    Accepted Submission(s): 3559


Problem Description
the second year of the university somebody started a study on the romantic relations between the students. The relation “romantically involved” is defined between one girl and one boy. For the study reasons it is necessary to find out the maximum set satisfying the condition: there are no two students in the set who have been “romantically involved”. The result of the program is the number of students in such a set.

The input contains several data sets in text format. Each data set represents one set of subjects of the study, with the following description:

the number of students
the description of each student, in the following format
student_identifier:(number_of_romantic_relations) student_identifier1 student_identifier2 student_identifier3 ...
or
student_identifier:(0)

The student_identifier is an integer number between 0 and n-1, for n subjects.
For each given data set, the program should write to standard output a line containing the result.
 

Sample Input
  
7 0: (3) 4 5 6 1: (2) 4 6 2: (0) 3: (0) 4: (2) 0 1 5: (1) 0 6: (2) 0 1 3 0: (2) 1 2 1: (1) 0 2: (1) 0
 

Sample Output
  
5 2
 

Source
 



#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<vector>
using namespace std;
const int maxn=11111;
vector<int>map[maxn];
int match[maxn],n,m,k,ans;
bool vis[maxn];
bool dfs(int u)
{
	for(int i=0;i<map[u].size();i++)
	{
		if(!vis[map[u][i]])
		{
			vis[map[u][i]]=true;
			if(match[map[u][i]]==-1||dfs(match[map[u][i]]))
			{
				match[map[u][i]]=u;
				return true;
			}
		}
	}
	return false;
}
void hangry()
{
	memset(match,-1,sizeof(match));
	ans=0;
	for(int i=0;i<n;i++)
	{
		memset(vis,false,sizeof(vis));
		if(dfs(i))
		{
			ans++;
		}
	}
}
int main()
{
	int u,v,num,i;
	while(scanf("%d",&n)==1)
	{
		num=n;
		for(i=0;i<n;i++)
		map[i].clear();
		while(num--)
		{
		scanf("%d: (%d)",&u,&m);
		for(i=1;i<=m;i++)
		{
			scanf("%d",&v);
			map[u].push_back(v);
		}
	   }
	   hangry();
	   printf("%d\n",n-ans/2);
    }
	return 0;
}



Teranex Express格式转换器 Teranex Express格式转换器 Teranex Express是一款可实时处理SD、HD和Ultra HD的广播级格式转换器!它配备先进的专利运算能力,可提供优质的无缝转换,是许多全球知名电视播出机构和电影制作公司的指定使用产品!Teranex Express可为您提供多达1089种具备10bit高品质SD、HD和Ultra HD上、下、格式转换!您还将获得高质量去隔行处理、降噪功能、下拉变换自动检测、移除以及甚至编辑后素材的校正、可调画幅尺寸设定和宽高比变换,所有处理都全面支持时间码以及多通道 阅读详情

相关推荐

JAV.zip_jaV.H0D_jav.com_jav513_javjobvideo日韩_vjav

yrtos_ MULTITASKING RTOS,.

JAVA101本土精选,AcWing 101. 最高的牛JAVA

题目知识点1、本题使用到了差分,因为要求的有牛可能的最大值,所以每头牛初始化为h,a,b之间要互相看得见,所以对中间的值都-12、是要对数据进行判重,yxc这边用到了set< pair< int,int> >来存储两个值并判重,但java里面就只能是转化成set里存储对象在判断,这样是不好判断的。我这边转化成set< String>,String=”“+a+b,...

weixin_29116255的博客 3万+

模型剪枝实战 | Torch-Pruning 库在YOLOv8上的应用指南

本文详细介绍了如何使用Torch-Pruning库对YOLOv8模型进行结构化剪枝,以实现模型“瘦身”。通过DepGraph(依赖图)技术自动处理层间依赖,确保剪枝安全。文章提供了从环境搭建、核心原理理解到完整剪枝流程的实战指南,并强调了剪枝后的微调与性能评估,帮助开发者在保持精度的同时显著提升模型推理速度。

weixin_29046035的博客 503

jav101上不去_去101

jav101上不去Similarly to mathematics, variables, in computer science, are placeholders that hold a value (to be more precise, a location that points to a value). Those variables are associated to four el...

weixin_26712121的博客 5万+

Windows安装Pytorch3d

pytorch和pytorch3d版本对应关系如下:https://github.com/facebookresearch/pytorch3d/releasescuda和NVIDIA CUB版本对应关系如下:https://github.com/NVIDIA/cub/releases?page=1本人配置如下:GPU:1050TiCUDA:11.1python:3.8。

Snakewood的博客 4286

大模型应用开发面试全流程实录:RAG、上下文工程与多Agent协作技术深度解析

Transformer 依靠多头自注意力和位置编码实现高效序列建模。Prompt Engineering包含多种设计思路,如 Zero-shot、Few-shot、Chain-of-thought,提升模型泛化和推理。Token 和上下文窗口直接影响模型性能与成本,选择需结合实际业务场景(如客服对话需长窗口)。Embedding 技术是 RAG 的基础,决定了语义检索效果。向量数据库如 FAISS、Milvus等分别适用于本地/分布式检索。

m0_52114506的博客 828

hdoj--1068--Girls and Boys(最大独立集)

Girls and Boys Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 9464    Accepted Submission(s): 4320 Problem Description the sec

playboy307 4万+

Linux之SUSE系统SAP-HANA经常系统内存不足使得SAP应用不能使用解决方案

问题描述 Linux内存使用量超过阈值,使得sap应用程序无可用内存,最终导致程序崩溃。 问题原因 自己查阅了一些资料,也基于zabbix的可用内存和实际不太一样入手去找原因发现问题出现于Cached的值过大,导致系统没有可以再分配的内存空间。Cached只要用来缓存文件的,经常读写的文件会被缓存到Cached中,可以增加读写效率,该功能是Linux系统内核提供的,而SAP-HANA的日志文件很大...

liuxiangyang_的博客 6710

hdu 1068 Girls and Boys(匈牙利算法求最大独立集)

Girls and Boys Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 7044    Accepted Submission(s): 3178 Problem Description the secon

Coding A World 1389

嵌入式设备的switch 以及PHY 芯片调试和选型 (1)

越来越的设备需要多网口的需求,于是需求搭配一个交换机实现网口的扩展。但是很多软件或是硬件工程师在实际选型和应用中经常会遇到一些问题。这里总结一下,避免大家采坑。 几个概念: MAC(介质访问控制),可以理解成数据链路层即可 PHY(物理性),简单理解层转成物理层的连接组件即可 控制接口(MDC/DMIO,I2C,...

睿峰的博客 1万+

暗黑破坏神2重制版 mod制作教程(一)

暗黑2重制版mod修改教程

hhhh2312的博客 7451

hdu1068 Girls and Boys(二分图最大独立集)

女孩和男孩 时间限制:20000/10000 MS(Java /其他)内存限制:65536/32768 K(Java /其他) 提交总数:15252接受提交:7211 问题描述 大学第二年,有人开始研究学生之间的恋爱关系。在一个女孩和一个男孩之间定义了“浪漫参与”关系。出于研究原因,有必要找出满足条件的最大集合:集...

一身清贫怎敢入繁华 426

【架构设计】DDD 到底解决了什么问题

DDD作为架构设计思想帮助微服务控制规模复杂度,那它是怎么做到的呢?第一章提出了架构的根本目是解决系统复杂度,并简要说明系统复杂度的六个来源及通用解法,为我们设计架构提供了清晰可执行的操作思路。

DreamSun的博客 1160

zoj 1137 || 1466 Girls and Boys

<br /> <br />二分图的最大独立集=顶点数-二分图的最大匹配数<br /><br /><br />二分图的最小顶点覆盖=二分图的最大匹配数<br /><br /><br />二分图的最小路径覆盖=顶点数-二分图的最大匹配数<br /> <br />zoj上居然没写数据范围。。。poj写了。<br /> <br />这题是求最大独立集。<br /> <br />给你 romantically involved 的关系,求出最多的不满足这个关系的集合数。<br /> <br />因为1-2 2-1 算

小媛在努力~ 2万+

Challenge 4 - OSCP A

在c盘下发现一个windows.old,在里面可以找到SYSTEM和SAM文件,下载到本地,利用samdump2解密发现没解出来,再来试试pwdump.py(https://github.com/CiscoCXSecurity/creddump7)得到压缩包密码bludecode,解压之后发现一个比较特殊的文件configuration.php,里面有两个类似密码的字符串。登录之后在/opt/backups/下发现几个特殊文件,其中sitebackup3.zip是个正常的压缩包。但是这个压缩包是有密码的。

羽的博客 5780

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

Girls and Boys POJ - 1466(最大独立集)

Girls and Boys POJ - 1466 In the second year of the university somebody started a study on the romantic relations between the students. The relation “romantically involved” is defined between one girl and one boy. For the study reasons it is necessary to f

rainbowsea_1的博客 383

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

【二分图|最大点独立集】POJ-1466 Girls and Boys

Girls and Boys Time Limit: 5000MS   Memory Limit: 10000K       Description In the second year of the university somebody started a study on the romantic relations between

JSure的代码库 907

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

POJ1446 Girls and Boys

Girls and Boys Time Limit: 5000MS   Memory Limit: 10000K Total Submissions: 12747   Accepted: 5678 Description In the second year of the university somebody started a

Jelly_acm的博客 4501

HDU【1068】Girls and Boys(最大独立集)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1068 分析 这道题考查最大独立集,同时它符合二分匹配的定义,所以用匈牙利算法来做,具体关系是最大独立集 = 顶点数 - 最大匹配,注意问题中是一个集合,所以最后最大匹配数要除以2,可以弄个简单的案例,如 6 0: (1) 3 1: (1) 4 2: (1) 5 3: (1) 0 4: (1) 1 5:...

yj8023xx的博客 306

hdu1068 Girls and Boys 最大独立集

the second year of the university somebody started a study on the romantic relations between the students. The relation “romantically involved” is defined between one girl and one boy. For the study r

ccsu_cherish 823

Girls and Boys——最大独立集二分匹配

Problem Description the second year of the university somebody started a study on the romantic relations between the students. The relation “romantically involved” is defined between one girl and one boy. For the study reasons it is necessary to find out

小白之比白更白的博客 221

Girls and Boys(二分图)

Girls and Boys Time Limit: 5000MS   Memory Limit: 10000K Total Submissions: 10059   Accepted: 4447 Description In the second year of the university somebody started a study

虽无鲲鹏翼,不坠凌云心 1043

hdu 1068 Girls and Boys(最大独立集·maxmatch匈牙利)

题目:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=19391 Girls and Boys Time Limit: 10000MS   Memory Limit: 32768KB   64bit IO Format: %I64d & %I64u Submit Sta

theArcticOcean 754

hdoj 1068 Girls and Boys

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1068 /*最大独立集问题(等于 定点数 - 最大匹配数) 题目大意为: 大学二年级的时候,一些同学开始研究男女同学之间的缘分。研究者试图找出没有 缘分同学的最大集。程序的结果就是要输出这个集合中学生的数量 */ #include using namespace std; const in

—— 然 之 1574

HDU 1068 Girls and Boys(最大独立集)

Girls and BoysTime Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 12791    Accepted Submission(s): 6066Problem Descriptionthe second year of the u...

BBHHTT的博客 299

HDU-1068-Girls and Boys(无向图独立集 模板)

题目 大学第二年,有人开始研究学生之间的恋爱关系。恋爱关系是指一个女孩和一个男孩之间的关系。由于研究的原因,有必要找出满足条件的最大集合:集合中没有两个学生“恋爱过”。程序的结果是这样一个集合中的学生数量。 输入包含几个文本格式的数据集。每个数据集代表一组研究对象,描述如下: 学生人数 每个学生的描述,格式如下 student_identifier:(number_of_romantic_rela...

qq_42576687的博客 5968
上一篇: Air Raid(最小路径覆盖数=节点数-最大匹配数)
下一篇: The Euler function
林下的码路
博客等级 码龄12年 295粉丝 506原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

林下的码路

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值