题目名称 3251. [POJ 1422]Air Raid
输入输出 airraid.in/out
难度等级 ★★☆
时间限制 1000 ms (1 s)
内存限制 16 MiB
测试数据 10
题目来源 Gravatar数声风笛ovo 于2019-10-28加入
开放分组 全部用户
提交状态
分类标签
二分图 匈牙利算法 网络流
分享题解
通过:6, 提交:12, 通过率:50%
Gravatar瑆の時間~無盡輪迴·林蔭 100 0.000 s 0.00 MiB C++
Gravatar张家旗 100 0.000 s 0.00 MiB C++
Gravatar梦那边的美好ET 100 0.005 s 13.67 MiB C++
GravatarShallowDream雨梨 100 0.006 s 13.70 MiB C++
Gravatar数声风笛ovo 100 0.006 s 13.83 MiB C++
Gravatarleon 100 0.007 s 13.83 MiB C++
Gravatar梦那边的美好ET 10 0.005 s 13.66 MiB C++
GravatarShallowDream雨梨 10 0.005 s 13.70 MiB C++
Gravatar张家旗 0 0.005 s 13.66 MiB C++
Gravatar张家旗 0 0.005 s 13.66 MiB C++
关于 Air Raid 的近10条评论(全部评论)
菜是原罪,dfs也能打歪来??
GravatarShallowDream雨梨
2019-10-29 14:09 2楼
菜是原罪,一个最小点覆盖还差点忘了用原点数去减
Gravatar瑆の時間~無盡輪迴·林蔭
2019-10-29 07:41 1楼

3251. [POJ 1422]Air Raid

★★☆   输入文件:airraid.in   输出文件:airraid.out   简单对比
时间限制:1 s   内存限制:16 MiB

【题目描述】

Consider a town where all the streets are one-way and each street leads from one intersection to another. It is also known that starting from an intersection and walking through town's streets you can never reach the same intersection i.e. the town's streets form no cycles.

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.


城镇里的街道从一个交叉口连接到另一个交叉口,街道都是单向的,并且从一个交叉口沿着街道出发不会回到相同的交叉口。伞兵降临在城镇的一个交叉口并可以沿着街道走向另一个没有被其他伞兵走过的交叉口,问城镇中的所有交叉口都被伞兵走过的情况下至少需要多少名伞兵。

【输入格式】

Your program should read sets of data. The first line of the input file contains the number of the data sets. Each data set specifies the structure of a town and has the format:

$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.


输入文件包含多组数据;

第一个数:数据组数 $T$,

每一组中,第一行代表交叉口数 $n$,第二行代表单向路的条数$m$,

接下来 $m$行每行两个数 $u$,$v$,代表单向路的起点和终点。

【输出格式】

The result of the program is on standard output. For each input data set the program prints on a single line, starting from the beginning of the line, one integer: the minimum number of paratroopers required to visit all the intersections in the town.


对于每一组数据,输出所有交叉口都被伞兵走过的情况下至少需要多少名伞兵。

【样例输入】

2
4
3
3 4
1 3
2 3
3
3
1 3
1 2
2 3

【样例输出】

2
1 

【提示】

对于全部的数据,保证有:

$3≤n≤120, 1≤u,v≤n$

【来源】

PKU JudgeOnline T1422