- #include <stdio.h>
- #include <string.h>
- #define MAX 102
- long n,n1,match;
- long adjl[MAX][MAX];
- long mat[MAX];
- bool used[MAX];
- FILE *fi,*fo;
- void readfile()
- {
- fi=fopen("flyer.in","r");
- fo=fopen("flyer.out","w");
- fscanf(fi,"%ld%ld",&n,&n1);
- long a,b;
- while (fscanf(fi,"%ld%ld",&a,&b)!=EOF)
- adjl[a][ ++adjl[a][0] ]=b;
- match=0;
- }
- bool crosspath(long k)
- {
- for (long i=1;i<=adjl[k][0];i++)
- {
- long j=adjl[k][i];
- if (!used[j])
- {
- used[j]=true;
- if (mat[j]==0 || crosspath(mat[j]))
- {
- mat[j]=k;
- return true;
- }
- }
- }
- return false;
- }
- void hungary()
- {
- for (long i=1;i<=n1;i++)
- {
- if (crosspath(i))
- match++;
- memset(used,0,sizeof(used));
- }
- }
- void print()
- {
- fprintf(fo,"%ld",match);
- fclose(fi);
- fclose(fo);
- }
- int main()
- {
- readfile();
- hungary();
- print();
- return 0;
- }