HDUOJ----2485 Destroying the bus stations

Destroying
the bus stations


Time
Limit: 4000/2000 MS (Java/Others)    Memory Limit:
32768/32768 K (Java/Others) Total Submission(s):
2072    Accepted Submission(s): 647

Problem Description

Gabiluso is one of the greatest spies in his country. Now
he’s trying to complete an “impossible” mission ----- to make it slow for the
army of City Colugu to reach the airport. City Colugu has n bus stations and m
roads. Each road connects two bus stations directly, and all roads are one way
streets. In order to keep the air clean, the government bans all military
vehicles. So the army must take buses to go to the airport. There may be more
than one road between two bus stations. If a bus station is destroyed, all roads
connecting that station will become no use. What’s Gabiluso needs to do is
destroying some bus stations to make the army can’t get to the airport in k
minutes. It takes exactly one minute for a bus to pass any road. All bus
stations are numbered from 1 to n. The No.1 bus station is in the barrack and
the No. n station is in the airport. The army always set out from the No. 1
station. No.1 station and No. n station can’t be destroyed because of the heavy
guard. Of course there is no road from No.1 station to No. n station.
Please
help Gabiluso to calculate the minimum number of bus stations he must destroy to
complete his mission.

Input

There are several test cases. Input ends with three
zeros.
For each test case:
The first line contains 3 integers, n, m and k.
(0< n <=50, 0< m<=4000, 0 < k < 1000) Then m lines follows.
Each line contains 2 integers, s and f, indicating that there is a road from
station No. s to station No. f.

Output

For each test case, output the minimum number of stations
Gabiluso must destroy.

Sample Input

5 7 3

1 3

3 4

4 5

1 2

2 5

1 4

4 5

0 0 0

Sample Output

2

Source

2008
Asia Regional Beijing

题意:

Gabiluso是

HDUOJ----2485 Destroying the bus stations

时间: 2024-10-15 21:19:02

HDUOJ----2485 Destroying the bus stations的相关文章

hdu 2485 Destroying the bus stations 迭代加深搜索

求最少去掉几个公交站使得从s到t的最短路径大于k. 迭代加深搜索. #include <cstdio> #include <cstring> #include <queue> using namespace std; #define maxn 60 #define maxm 50000 int n,m,K,cnt,up; int head[maxn],pre[maxn]; int road[maxn][maxn]; bool del[maxn]; queue<in

HDU 2485 Destroying the bus stations(费用流)

http://acm.hdu.edu.cn/showproblem.php?pid=2485 题意: 现在要从起点1到终点n,途中有多个车站,每经过一个车站为1时间,现在要在k时间内到达终点,问至少要破坏多少个车站. 思路: 把每个点拆分为两个点,容量为1,费用为0.之后相邻的车站连边,容量为INF,费用为1,表示经过一个车站需要1时间. 这样一来,跑一遍费用流计算出在费用不大于k的情况下的最大流,也就是最小割,即至少要破坏的车站数. 在网络中寻求关于f的最小费用增广路,就等价于在伴随网络中寻求

hdu 2485 Destroying the bus stations 最小费用最大流

题意: 最少需要几个点才能使得有向图中1->n的距离大于k. 分析: 删除某一点的以后,与它相连的所有边都不存在了,相当于点的容量为1.但是在网络流中我们只能直接限制边的容量.所以需要拆点来完成对的点容量的限制.对于边i -> j,先建边i ->i',再建i'->j.i ->i'只能建一次,容量为1,费用为0.i'->j的容量是INF.此题中因为已经有源点,所以源点(1)不能限制容量. 1 #include<iostream> 2 #include<c

HDU 2485 Destroying the bus stations

2015 ACM / ICPC 北京站 热身赛 C题 #include<cstdio> #include<cstring> #include<cmath> #include<queue> #include<vector> #include<algorithm> using namespace std; const int INF=0x7FFFFFFF; const int maxn=50+10;//点的数量 int n,m,k; in

Destroying the bus stations (hdu 2485 网络流+最短路)

Destroying the bus stations Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2313    Accepted Submission(s): 739 Problem Description Gabiluso is one of the greatest spies in his country. Now he'

Destroying the bus stations

hdu2485:http://acm.hdu.edu.cn/showproblem.php?pid=2485 题意:给你一个图,让你删除其中的一些点,然后使得1到n的最小距离大于k,求删除的最小的点数. 题解:DFS枚举最短路径上的点. 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<queue> 6 #def

HDU2485 Destroying the bus stations(最小割---点割)

Destroying the bus stations Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2319    Accepted Submission(s): 743 Problem Description Gabiluso is one of the greatest spies in his country. Now he'

题单二:图论500

http://wenku.baidu.com/link?url=gETLFsWcgddEDRZ334EJOS7qCTab94qw5cor8Es0LINVaGMSgc9nIV-utRIDh--2UwRLvsvJ5tXFjbdpzbjygEdpGehim1i5BfzYgYWxJmu ==========  以下是最小生成树+并查集=========================[HDU]1213         How Many Tables        基础并查集★1272         小

图论五百题!

生死看淡不服就淦,这才是人生! =============================以下是最小生成树+并查集======================================[HDU]1213 How Many Tables 基础并查集★1272 小希的迷宫 基础并查集★1325&&poj1308 Is It A Tree? 基础并查集★1856 More is better 基础并查集★1102 Constructing Roads 基础最小生成树★1232 畅通工程 基