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
我么你先考虑,最大流,如果一个图中让你删掉N个点使得源点不能到达汇点, 这里设置边的流量为1,然后一边最大流即可。
然后我们要考虑每条路只能走一遍,所以不能直接连中间的点,要限流建图,将中间的点,一分为2,左边作为起始点,右边作为终止点,流量设置为1,这样就可现之每条边之走一遍(这样想,省略了最小割转化分过程,我一直认为最小割最大流没啥区别),现在有个K的限制,我们怎么办呢?之前我们不是拆点了?那么对于源点到左边的起始点的距离加上起始点到右边终止点的距离再加上终止点到原点的距离小于K不就可以了吗,大于K已经不可能在K时间内到达了,忽略即可!
明了点就是
一个点拆成了 I和I' 如果dis[s][u]+dis[u][v]+dis[v][t]<=K的话,我们就添一条U到V',注意是V一撇。然后最大刘 能赵四谢广坤。