Title Description  Description

Suyuan Experimental School of Guangzhou No.2 Middle School has n A club , Use them separately 1 To n Number .
Suyuan Experimental School of Guangzhou No.2 Middle School has m personal , Use them separately 1 To m Number . Everyone can join one or more clubs , You can also not join any club .
Every club needs to choose a representative . Brother Qian hopes more people can become representatives .

Input description  Input Description

In the first line, enter two numbers n and m.
following n There are several numbers in each row , These numbers are no more than m The positive integer . Among them the first i The number of rows represents the community i All members of . Use one... For each line 0 end .

Output description  Output Description

The number of people who can be representatives with the largest output .

The sample input  Sample Input

4 4
1 2 0
1 2 0
1 2 0
1 2 3 4 0

Sample output  Sample Output

3

```// Naked Hungarian algorithm
#include<cstdio>
#include<iostream>
#include<cstring>
#define M 210
using namespace std;
int used[M],belong[M],a[M][M],n,m;
int find(int i)
{
for(int j=;j<=n;j++)
if(!used[j]&&a[i][j])
{
used[j]=;
if(!belong[j]||find(belong[j]))
{
belong[j]=i;
return ;
}
}
return ;
}
int main()
{
scanf("%d%d",&n,&m);
for(int i=;i<=n;i++)
{
int x;
while()
{
scanf("%d",&x);
if(!x)break;
a[x][i]=;
}
}
int tot=;
for(int i=;i<=m;i++)
if(find(i))
{
memset(used,,sizeof(used));
tot++;
}
printf("%d",tot);
return ;
}```

## Looking for the representative element (codevs 2776) More articles about

1. hungarian algorithm codevs 2776 Looking for the representative element

codevs 2776 Looking for the representative element   The time limit : 1 s   Space restriction : 256000 KB   Question level : gold Gold Title Description  Description Suyuan Experimental School of Guangzhou No.2 Middle School has n A club , Use them separately ...

2. Codevs 2776 Looking for the representative element ( Bipartite map matching )

2776 Looking for the representative element The time limit : 1 s Space restriction : 256000 KB Question level : gold Gold Title Description Description Suyuan Experimental School of Guangzhou No.2 Middle School has n A club , Use them separately 1 To n Number . Guangzhou 2 ...

3. Codevs2776 Looking for the representative element

2776 Looking for the representative element The time limit : 1 s   Space restriction : 256000 KB   Question level : gold Gold    Title Description  Description Suyuan Experimental School of Guangzhou No.2 Middle School has n A club , Use them separately 1 To n Number ...

4. CJOJ 1943 【 Chongqing No.8 Middle School simulation competition 】 Looking for the representative element （ Maximum matching of bipartite graph ）

CJOJ 1943 [ Chongqing No.8 Middle School simulation competition ] Looking for the representative element ( Maximum matching of bipartite graph ) Description There are... In No.8 Middle School n A club , Use them separately 1 To n Number . There are... In No.8 Middle School m personal , Use them separately 1 To m Number . Everyone can join one or more clubs , also ...

5. RQNOJ PID141 / Looking for the representative element [2017 year 6 Monthly plan Bipartite graph 01]

PID141 / Looking for the representative element * Submit your code Check out the discussion and solution 1 Before the minute My state Passed 2017-06-28 21:03:46 Running time :31 ms Run a memory :28048 KB View the last evaluation record ...

6. codevs.cn 2776 Looking for the representative element The maximum flow method

website :http://codevs.cn/problem/2776/ The main idea of the topic : n A club ,m personal , Each club can have one person as its representative , Each person can serve as more than one representative , How many people are representatives at most . Ideas : You can build a map , then ...

7. 【codevs】2776 Looking for the representative element

Title Description  Description Suyuan Experimental School of Guangzhou No.2 Middle School has n A club , Use them separately 1 To n Number . Suyuan Experimental School of Guangzhou No.2 Middle School has m personal , Use them separately 1 To m Number . Everyone can join one or more clubs , You can also not join any club . Every club ...

8. codevs 2776 Looking for the representative element

The time limit : 1 s   Space restriction : 256000 KB   Question level : gold Gold     Title Description  Description Suyuan Experimental School of Guangzhou No.2 Middle School has n A club , Use them separately 1 To n Number . Su Yuan experiment of Guangzhou No.2 Middle School ...

9. 【 Bipartite graph 】【 The biggest match 】【 hungarian algorithm 】CODEVS 2776 Looking for the representative element

Naked Hungary , Save template . #include<cstdio> #include<vector> #include<cstring> using namespace std ...

## Random recommendation

1. 【 dried food 】” One of the first “ .NET Core Verification code components

Preface as everyone knows ,Dotnet Core There are no graphics at the moment API, Former System.Drawing The assembly is not included in Dotnet Core 1.0 Environment . But in the dotnet core labs You can see in the project ...

2. jface databinding: Part of the implementation POJO Monitoring of objects

In the previous post <jface databinding/PojoBindable Realize to POJO Object support   > in , We already know that it's directly related to POJO Object to modify , It can't be bound UI Components know , In the last article ...

3. Linux configure network YUM Source

configure network yum Source RHEL6.5 [root@xuegod163 ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun ...

4. machine learning (Machine Learning)&amp; Deep learning (Deep Learning) Information

<Brief History of Machine Learning> Introduce : This is an article about the history of machine learning , The introduction is very comprehensive , From the perceptron . neural network . Decision tree .SVM.Adaboost To random forest .D ...

First of all, implement the renderings on the screen , I don't know how to do dynamic graphics , Just make do with it Using an open source control on the Internet viewpagerindicator, You can customize the tags displayed when switching , Dot , Or underline . GrildView It shows everything on the phone a ...

6. python3 Chinese character coding problem

Recently, while doing a web crawler , I'm very upset by the coding problem of Chinese , Especially in windows In the environment . 1. Crawled to the Chinese Web page content , Parsing error occurred during parsing In general , We all use urllib The correlation function in , Conduct web Page crawling , ...

7. Interview questions 32. from 1 To n In integers 1 Number of occurrences

subject : Enter an integer n, Seek from 1 To n this n In the decimal representation of an integer 1 Number of occurrences . For example, the input 12, from 1 To 12 These integers contain 1 In the number of 1,10,11 and 12,1 All in all 5 Time This problem can be directly variable 1 To n Of n Then count them separately ...

8. elasticsearch Cluster building example

elasticsearch Cluster building example We're going to start searching again next month , It hasn't moved for several months. Fortunately, it hasn't fallen down .  In the evening, I built a simple search cluster on my virtual machine , Share it . Operating system environment : Red Hat 4.8.2-16 el ...

9. Java Data types and their conversions in （ turn ）

Java Data types and their conversions in Basic data types There are four basic types :1)int The length data types are :byte(8bits).short(16bits).int(32bits).long(64bits).2 ...

10. 《React Design patterns and best practices 》 note

In the book demo All are 15.3.2 The following versions of , There are some demo Use the latest react 16.x The version will report an error , Remember to change the version when installing the package   Chapter one React Basics Imperative programming describes how code works , And declarative programming means that you want to ...