| 记录编号 | 271527 | 评测结果 | AAAAAAAAAA | 
    
        | 题目名称 | 1168.机器调度 | 最终得分 | 100 | 
    
        | 用户昵称 |  安呐一条小咸鱼。 | 是否通过 | 通过 | 
    
        | 代码语言 | C++ | 运行时间 | 0.005 s | 
    
        | 提交时间 | 2016-06-16 07:52:00 | 内存使用 | 0.43 MiB | 
    
    
    
    		显示代码纯文本
		
		#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn=5050;
int n,m,k,mode_a,mode_b,tot=0,tmp;
int head[maxn],match[maxn];
bool v[maxn];
struct Node
{
	int to,next;
}edge[maxn<<1];
void Addedge(int x,int y)
{
	edge[++tot].to=y;
	edge[tot].next=head[x];
	head[x]=tot;
}
bool dfs(int y)
{
	for(int i=head[y];i;i=edge[i].next)
	{
		int p=edge[i].to;
		if(!v[p])
		{
			v[p]=1;
			if(!match[p]|| dfs( match[p] ) )
			{
				match[p]=y;
				return true;
			}
		}
	}
	return false;
}
int main()
{
	//while(1)
	//{
	freopen("machine.in","r",stdin);
	freopen("machine.out","w",stdout);
		memset(head,0,sizeof(head));
		memset(edge,0,sizeof(edge));
		tot=0;
		scanf("%d%d%d",&n,&m,&k);
		for(int i=1;i<=k;i++)
		{
			scanf("%d%d%d",&tmp,&mode_a,&mode_b);
			if(mode_a!=0 && mode_b!=0)
			{
				Addedge(mode_a,mode_b);
			}
		}
		//scanf("%d",&tmp);
		int ans=0;
		for(int i=1;i<n;i++)
		{
			memset(v,0,sizeof(v));
			if( dfs(i) )ans++;
		}
		printf("%d\n",ans);
	//	if(tmp==0)break;
	//}
	//system("pause");
	return 0;
}