B - Girls and Boys(二分图与匈牙利算法)

点击打开链接

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
 

题解:0: (3) 4 5 6 的意思是0-5,0-4,0-6匹配

代码

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int f[505],fr[505][505];
int vis[505];
int n;
bool find(int x)
{
	for(int i=0;i<n;i++)
    {
    	if(fr[x][i]&&!vis[i])
    	{
    		vis[i]=true;
    		if(f[i]==-1||find(f[i]))
    		{
    			f[i]=x;
    			return true;
			}
		}
	}
	return false;
}
int main()
{
	
	while(scanf("%d",&n)!=EOF)
	{
		memset(f,-1,sizeof(f));
		memset(fr,false,sizeof(fr));
		for(int i=1;i<=n;i++)
		{
			int a,b;
			scanf("%d: (%d)",&a,&b);
			while(b--)
			{
				int t;
				scanf("%d",&t);
				fr[a][t]=true;
				fr[t][a]=true;
			}
		}
		int ans=0;
		for(int i=0;i<n;i++)
		{
			memset(vis,false,sizeof(vis));
			if(find(i))
			ans++;
		}
		ans=n-(ans/2);
		//顶点数 - 最大配对数 = 最大独立集数(因为是把集合扩大了1倍,所以除以2)   
		printf("%d\n",ans);
	}
	return 0;
}











  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 图像去雾是一种图像增强技术,能够消除图像中由雾霾或大气污染导致的模糊和低对比度的问题。对于女孩图片的去雾过程,首先需要对图像进行预处理,包括调整亮度、对比度和色彩平衡等。然后,可以采用不同的去雾算法,如暗通道先验算法或Retinex算法,来恢复图像的清晰度和细节。 在暗通道先验算法中,通过分析图像中的暗通道进行去雾。暗通道是指图像中像素的最小通道值(例如,RGB图像中的最小的R、G和B通道值)。该算法利用自然景物普遍具有暗通道低值的特点,通过计算图像的全局大气光和局部大气光来减小雾霾效果。 另一种常用的算法是Retinex算法,基于对图像中的光照和反射成分进行分解。通过将图像分解为反射成分和光照成分,可以减少雾霾对图像的影响并提高图像质量。Retinex算法能够改善图像的对比度、色彩饱和度和细节。 无论使用哪种算法,图像去雾的成功还取决于输入图像的质量和算法参数的调整。通过适当的参数设置和算法选择,女孩图片的去雾可以使图像更加清晰,细节更加丰富,给人一种更加真实和美丽的感觉。 ### 回答2: 图像去雾是一种图像处理技术,可以用于改善雾天或者雾气较重照片的质量。通过去除照片中的雾霾或雾气,可以让图片更加清晰明亮,还原真实的景物。 针对女生的照片进行图像去雾处理,可以使女生的肤色更加细腻光滑,增加皮肤的自然亮度和鲜活感。在雾气重的照片中,女生的面部特征可能会受到模糊或变形的影响,去雾处理可以恢复面部的细节和轮廓,使得女生更加美丽动人。 此外,图像去雾还可以增强画面的色彩饱和度和对比度,使得女生的服装、配饰和背景等元素更加鲜艳明亮。同时,去除雾霾后的照片可以减少画面中的混沌感,让女生成为画面的焦点,更加突出与背景的对比,达到更好的视觉效果。 总之,图像去雾处理对于女生的照片可以提升照片的质量和美观度,让女生的魅力更加突显。无论是在个人摄影作品中展示自己的美丽,还是在社交媒体上与朋友分享时,经过去雾处理的女生照片都能更好地展现出女生的青春活力和魅力。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值