#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std; #define MAXN 150
int n; //十字路口的数量
int m; //路的个数
int map[MAXN][MAXN];
int x[MAXN], y[MAXN];
int mark[MAXN]; int search(int a)
{
for (int i = ; i <= n; i++)
{
if (map[a][i] && !mark[i])
{
mark[i] = ;
if (y[i] == || search(y[i]))
{
x[a] = i;
y[i] = a;
return a;
}
}
}
return ;
} int main()
{
int t;
scanf("%d", &t);
while (t--)
{
memset(map, , sizeof(map));
memset(mark, , sizeof(mark));
scanf("%d %d", &n, &m);
for (int i = ; i < m; i++)
{
int a, b;
scanf("%d %d", &a, &b);
if (map[a][b] == )
map[a][b] = ;
} int ans1 = ;
memset(x, , sizeof(x));
memset(y, , sizeof(y)); for (int i = ; i <= n; i++)
{
if (x[i] == )
{
memset(mark, , sizeof(mark));
if (search(i))
ans1++;
}
}
printf("%d\n", n - ans1);
}
//system("pause");
return ;
}

hdu1151 Air Raid 基础匈牙利的更多相关文章

  1. HDU1151 Air Raid —— 最小路径覆盖

    题目链接:https://vjudge.net/problem/HDU-1151 Air Raid Time Limit: 2000/1000 MS (Java/Others)    Memory L ...

  2. Hdu1151 Air Raid(最小覆盖路径)

    Air Raid Problem Description Consider a town where all the streets are one-way and each street leads ...

  3. hdu1151 Air Raid

    http://acm.hdu.edu.cn/showproblem.php?pid=1151 增广路的变种2:DAG图的最小路径覆盖=定点数-最大匹配数 #include<iostream> ...

  4. hdu1151 Air Raid,DAG图的最小路径覆盖

    点击打开链接 有向无环图的最小路径覆盖 = 顶点数- 最大匹配 #include <queue> #include <cstdio> #include <cstring& ...

  5. hdu1151 Air Raid 二分匹配

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1151 求最小路径覆盖 二分图最小路径覆盖=点的个数-最大匹配. 代码: #include<ios ...

  6. Air Raid[HDU1151]

    Air RaidTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submis ...

  7. hdu1151 二分图(无回路有向图)的最小路径覆盖 Air Raid

    欢迎参加——BestCoder周年纪念赛(高质量题目+多重奖励) Air Raid Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65 ...

  8. HDU1151:Air Raid(最小边覆盖)

    Air Raid Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Su ...

  9. 【网络流24题----03】Air Raid最小路径覆盖

    Air Raid Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Su ...

随机推荐

  1. Android 平板中 自己定义键盘(popuwindow) 居于屏幕左下方 仿微信的password输入界面

          之前博客中,介绍过使用谷歌提供的键盘的一些api,能够非常好地自己定义键盘,參考我之前的博客链接:android 自己定义键盘 ,这个有一个局限性,仅仅能占满屏幕,无法做到仅仅能占一部分的 ...

  2. 利用ms17_010漏洞实验

    1.理论 在MSF里面msfconsole可以说是最流行的一个接口程序.但是msfconsole真的是一个强大的接口程序.Msfconsole提供了一个一体化的集中控制台.通过msfconsole,你 ...

  3. ribbon负载均衡进行服务消费

    相同服务以不同端口形式注册到eureka上,ribbon从eureka上获取冰进行服务消费,会偶现如下现象: I/O error on GET request for "http://COM ...

  4. 流媒体开发之开源项目live555---live555 server 编译 包括更改帧率大小

    由于要测试8148解码器的性能,需要搭建不同帧率25fps - >30fps,宏块大小defualt 100 000 -> 200 000不同大小的h264码流,所以就需要编译改动的liv ...

  5. Git使用之Permission Denied问题解决

    今天碰到了Git的Permission Denied问题. 在安装好git之后,我们通常会配置username和邮箱 git config --global user.name "zengj ...

  6. What is the difference between message queue pattern and publish-subscribe?

    What is the difference between message queue pattern and publish-subscribe? - Quora https://www.quor ...

  7. JasperReport 中文问题解决

    1 运行环境    1.1 JasperReport 3.5    JasperReports 是iReport的核心内容.它是一个强有力的开源报表产生工具,可以将内容输出到屏幕上.打印机或生成PDF ...

  8. vscode部分文件夹无法打开

    vscode部分文件夹无法打开,无法正常显示 解决方案:关闭该IDE.找到C:\Users\XX\AppData\Roaming\Code,将Code文件夹删除.重新打开vsCode,即可恢复.但是以 ...

  9. 将异常(getStackTrace)转化成String

    方法一: private static String getStackMsg(Exception e) { StringBuffer sb = new StringBuffer(); StackTra ...

  10. POJ2955 Brackets —— 区间DP

    题目链接:https://vjudge.net/problem/POJ-2955 Brackets Time Limit: 1000MS   Memory Limit: 65536K Total Su ...