#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector> using namespace std; #define N 101 int match[N];
bool vis[N];
vector <int> e[N];
int n, m, k; void InitRead(); void DataProcess(); bool Dfs(int x); int main()
{
while (~scanf("%d", &n))
{
if (n == 0) break;
InitRead();
DataProcess();
}
return 0;
} void InitRead()
{
scanf("%d %d", &m, &k);
memset(match, -1, sizeof(match));
for (int i=0; i<N; ++i) e[i].clear();
int a, b;
for (int i=0; i<k; ++i)
{
scanf("%*d %d %d", &a, &b);
if (a == 0 || b == 0) continue; //可以用模式0解决的任务不建边
e[a].push_back(b);
}
return;
} void DataProcess()
{
int ans = 0;
for (int i=0; i<n; ++i)
{
memset(vis, false, sizeof(vis));
if (Dfs(i)) ans++;
}
printf("%d\n", ans);
return;
} bool Dfs(int x)
{
int size = e[x].size();
for (int i=0; i<size; ++i)
{
if (!vis[e[x][i]])
{
vis[e[x][i]] = true;
if (match[e[x][i]] == -1 || Dfs(match[e[x][i]]))
{
match[e[x][i]] = x;
return true;
}
}
}
return false;
}

最新文章

  1. 任务调度框架-Quartz.Net
  2. ExtJs TreePanel 使用帮助
  3. a++ ++a 文件上传函数错误 smarty模板特点
  4. Android应用集成支付宝接口的简化
  5. Fedora安装
  6. var foo= {} ;foo.method() 和 单例模式有什么区别
  7. HTML标签CSS属性默认值汇总
  8. MySQL存储引擎差异化实验
  9. &lt;验证码的产生&gt;C语言---验证码的产生和验证
  10. 单例设计模式 Single
  11. 查看Zookeeper服务器状态信息的一些命令
  12. python Http协议
  13. ABP入门系列(1)——通过模板创建MAP版本项目
  14. Chrome浏览器添加控件
  15. Codeforces Round #442 (Div. 2) E Danil and a Part-time Job (dfs序加上一个线段树区间修改查询)
  16. Java实现三大简单排序算法
  17. php 日期和时间
  18. mysql时间函数和时间操作
  19. 基于MINA实现server端心跳检测(KeepAliveFilter)
  20. awk处理excel表格数据

热门文章

  1. threading.local的作用?
  2. centos7 使用postgres
  3. Open AI Gym简介
  4. C#聚合运算方法
  5. 说说JavaScript 中的new吧
  6. inline-block元素的4px空白间距解决方案
  7. ll指令输出解析
  8. codeforces 686B
  9. 3.微信小程序-B站:wxml和wxss文件
  10. JQuery- JQuery学习