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 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.

Input

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 (n <=500 ), for n subjects.

Output

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

Southeastern Europe 2000

最大独立集=点数-最大匹配数
求最大匹配数用匈牙利算法
#include <iostream>
#include <vector>
#include <queue>
#include <cstdio>
#include <cstring>

using namespace std;

#define MAXN 501

int match[MAXN];
vector<int> g[MAXN];
bool used[MAXN];
int n;

bool DFS(int x)
{
    for (int i = 0; i < g[x].size(); ++i)
    {
        int v = g[x].at(i);
        if (used[v] == false)
        {
            used[v] = true;
            if (match[v] == -1 || DFS(match[v]))
            {
                match[v] = x;
                return true;
            }
        }
    }
    return false;
}

int Hungry()
{
    int tot = 0;
    memset (match, -1, sizeof (match));
    for (int i = 0; i < n; ++i)
    {
        memset (used, false, sizeof(used));
        tot += (int)DFS(i);
    }
    return tot;
}

int main()
{
    int x, u, c;
    while (scanf("%d", &n) != EOF)
    {
        for (int i = 0; i < n; ++i)
            g[i].clear();
        for (int i = 0; i < n; ++i)
        {
            scanf("%d: (%d)",&u ,&c);
            while (c--)
            {
                scanf("%d", &x);
                g[u].push_back(x);
            }
        }
        printf("%d\n", n - (Hungry() >> 1));
    }
    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、付费专栏及课程。

余额充值