博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDOJ---1068 Girls and Boys[匈牙利算法]
阅读量:6942 次
发布时间:2019-06-27

本文共 2219 字,大约阅读时间需要 7 分钟。

 

Girls and Boys

Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 4471    Accepted Submission(s): 1944

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
 
 

 

 

模版:

1 bool 寻找从k出发的对应项出的可增广路 2 { 3     while (从邻接表中列举k能关联到顶点j) 4     { 5         if (j不在增广路上) 6         { 7             把j加入增广路; 8             if (j是未盖点 或者 从j的对应项出发有可增广路) 9             {10                 修改j的对应项为k;11                 则从k的对应项出有可增广路,返回true;12             }13         }14     }15     则从k的对应项出没有可增广路,返回false;16 }17 void 匈牙利hungary()18 {19     for i->1 to n20     {21         if (则从i的对应项出有可增广路)22             匹配数++;23     }24     输出 匹配数;25 }

匈牙利算法,模版

code:

1 #include 
2 #include
3 #include
4 #include
5 #include
6 #include
7 #include
8 #include
9 #include
10 #include
11 #include
12 #include
13 #include
14 #include
15 #include
16 #include
17 #include
18 #include
19 using namespace std;20 21 #define MAXN 100222 23 int data[MAXN][MAXN];24 int vst[MAXN];25 int path[MAXN];26 int n;27 28 int dfs(int v)29 {30 int i,j;31 for(i=0;i

 

转载地址:http://rnanl.baihongyu.com/

你可能感兴趣的文章
Keepalived安装配置
查看>>
韩遭史上最大规模****** 3500万客户信息泄露
查看>>
Building a Dynamic UI with Fragments
查看>>
vue中的数据绑定
查看>>
css中tabel-cell属性的简单总结
查看>>
Servlet底层原理
查看>>
form表单的两种提交方式,submit和button的用法
查看>>
mariadb数据库
查看>>
计算机之计算的实现
查看>>
2.16 umask
查看>>
Java之品优购课程讲义_day12(3)
查看>>
pyhanlp 停用词与用户自定义词典功能详解
查看>>
深度解析Tengine的调试与资源监控方法论
查看>>
常见天气api
查看>>
linux实战---基于KVM虚拟化搭建LAMP
查看>>
创建一个jdbc连接
查看>>
HBase原理——要弄懂的sequenceId
查看>>
CentOS中部署Docker并配置Nginx
查看>>
学习云计算哪里好?云计算新的前景出路
查看>>
解决已经装了telnet还是无法使用的问题
查看>>