poj——1422 Air Raid
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 8577 | Accepted: 5127 |
Description
With these assumptions your task is to write a program that finds the minimum number of paratroopers that can descend on the town and visit all the intersections of this town in such a way that more than one paratrooper visits no intersection. Each paratrooper lands at an intersection and can visit other intersections following the town streets. There are no restrictions about the starting intersection for each paratrooper.
Input
no_of_intersections
no_of_streets
S1 E1
S2 E2
......
Sno_of_streets Eno_of_streets
The first line of each data set contains a positive integer no_of_intersections (greater than 0 and less or equal to 120), which is the number of intersections in the town. The second line contains a positive integer no_of_streets, which is the number of streets in the town. The next no_of_streets lines, one for each street in the town, are randomly ordered and represent the town's streets. The line corresponding to street k (k <= no_of_streets) consists of two positive integers, separated by one blank: Sk (1 <= Sk <= no_of_intersections) - the number of the intersection that is the start of the street, and Ek (1 <= Ek <= no_of_intersections) - the number of the intersection that is the end of the street. Intersections are represented by integers from 1 to no_of_intersections.
There are no blank lines between consecutive sets of data. Input data are correct.
Output
Sample Input
2 4 3 3 4 1 3 2 3 3 3 1 3 1 2 2 3
Sample Output
2 1 题目大意:在一个城镇,有n个路口,和m条路,这些路都是单向的,而且路不会形成环,现在要弄一些伞兵去巡查这个城镇,伞兵只能沿着路的方向走,问最少需要多少伞兵才能把所有的路口城镇搜一遍(每个城镇只能搜一遍) 思路:最小路径覆盖裸题:最小路径覆盖=总点数-最大匹配数代码:
#include<cstdio> #include<cstdlib> #include<cstring> #include<iostream> #include<algorithm> #define N 1010 using namespace std; bool vis[N]; int t,n,m,x,y,ans,girl[N],map[N][N]; int read() { ,f=; char ch=getchar(); ; ch=getchar();} +ch-';ch=getchar();} return x*f; } int find(int x) { ;i<=n;i++) { if(!vis[i]&&map[x][i]) { vis[i]=true; ||find(girl[i])) {girl[i]=x;;} } } ; } int main() { t=read(); while(t--) { n=read(),m=read();ans=; memset(map,,sizeof(map)); memset(girl,-,sizeof(girl)); ;i<=m;i++) x=read(),y=read(),map[x][y]=; ;i<=n;i++) { memset(vis,,sizeof(vis)); if(find(i)) ans++; } printf("%d\n",n-ans); } ; }
poj——1422 Air Raid的更多相关文章
- POJ 1422 Air Raid(二分图匹配最小路径覆盖)
POJ 1422 Air Raid 题目链接 题意:给定一个有向图,在这个图上的某些点上放伞兵,能够使伞兵能够走到图上全部的点.且每一个点仅仅被一个伞兵走一次.问至少放多少伞兵 思路:二分图的最小路径 ...
- poj 1422 Air Raid (二分匹配)
Air Raid Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 6520 Accepted: 3877 Descript ...
- poj 1422 Air Raid 最少路径覆盖
题目链接:http://poj.org/problem?id=1422 Consider a town where all the streets are one-way and each stree ...
- POJ 1422 Air Raid
题目链接: http://poj.org/problem?id=1422 Description Consider a town where all the streets are one-way a ...
- POJ 1422 Air Raid (最小路径覆盖)
题意 给定一个有向图,在这个图上的某些点上放伞兵,可以使伞兵可以走到图上所有的点.且每个点只被一个伞兵走一次.问至少放多少伞兵. 思路 裸的最小路径覆盖. °最小路径覆盖 [路径覆盖]在一个有向图G( ...
- POJ - 1422 Air Raid 二分图最大匹配
题目大意:有n个点,m条单向线段.如今问要从几个点出发才干遍历到全部的点 解题思路:二分图最大匹配,仅仅要一条匹配,就表示两个点联通,两个点联通仅仅须要选取当中一个点就可以,所以有多少条匹配.就能够减 ...
- POJ - 1422 Air Raid(DAG的最小路径覆盖数)
1.一个有向无环图(DAG),M个点,K条有向边,求DAG的最小路径覆盖数 2.DAG的最小路径覆盖数=DAG图中的节点数-相应二分图中的最大匹配数 3. /* 顶点编号从0开始的 邻接矩阵(匈牙利算 ...
- POJ——T 1422 Air Raid
http://poj.org/problem?id=1422 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 8579 A ...
- POJ 1442 Air Raid(DAG图的最小路径覆盖)
题意: 有一个城镇,它的所有街道都是单行(即有向)的,并且每条街道都是和两个路口相连.同时已知街道不会形成回路. 可以在任意一个路口放置一个伞兵,这个伞兵会顺着街道走,依次经过若干个路口. 问最少需要 ...
随机推荐
- 大步小步法(BSGS) 学习笔记
\(\\\) BSGS 用于求解关于 \(x\) 的方程: \[ a^x\equiv b\pmod p\ ,\ (p,a)=1 \] 一般求解的是模意义下的指数,也就是最小非负整数解. \(\\\) ...
- hihocoder 神奇字符串
思路: 暴力,模拟. 实现: #include <iostream> #include <algorithm> #include <cstdio> #include ...
- [BZOJ2456]mode 其它
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2456 这道题有着神奇的内存限制1MB也就是说我们是没办法把读入的数字存下来的. 由于答案求 ...
- [BZOJ1878][SDOI2009]HH的项链 莫队
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1878 不带修改的莫队,用一个桶记录一下当前区间中每种颜色的数量就可以做到$O(1)$更新了 ...
- 浅谈网上的zoomlistview存在的问题
最近项目主要是做一个类似wps文档阅历的功能,以列表的形式显示文档,并且需要实现缩放平移.而网上关于此类功能的实现主要是通过自定义的listview实现的,类名为ZoomListView. 网上的zo ...
- 忘记dba用户密码,利用SQLPlus重置dba密码
打开SQL Plus 输入用户名: sys as sysdba 输入口令:可直接回车 连接到: Oracle Database 11g Enterprise Edition Release 11.2. ...
- iTOP-4418/6818开发板支持锂电池供电方案
iTOP-4418/6818开发板支持的是官方推荐的AXP228电池管理,动态调频,更稳定可靠,支持充放电电路与电量计(库化计), 广泛应用于各种电子产品中. 4418开发板中锂电池充放电接口,适用于 ...
- Zookeeper系列(一)
一.ZooKeeper的背景 1.1 认识ZooKeeper ZooKeeper---译名为“动物园管理员”.动物园里当然有好多的动物,游客可以根据动物园提供的向导图到不同的场馆观赏各种类型的动物,而 ...
- C#在sql中使用變量訪問Oracle數據庫
1.首先創建一個測試數據表 CREATE TABLE people ( SNO BYTE), SNAME BYTE), SSEX BYTE), SAGE number, SDEPT BYTE), BT ...
- asp 读取 另外一个带参数的asp文件(服务器不支持!放弃吧!骚年!)
(服务器不支持!放弃吧!骚年!) 主要作用是为了分离数据库,灵感是这样的:收到json影响,把asp里的数据,用一个页面输出,然后用另外一个页面读取,这样就不用有数据库位置的烦恼了 代码 网上有很多, ...