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
 
此题是最大最小流/现在还在温习中....!
题意:
Gabiluso是
 贴一下
代码:

 #include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<algorithm> using namespace std; const int maxm = ; //最大边数
const int maxn = ; //最大点数 struct aaa
{
int s,f,next ;
}; aaa c[maxm];
int sta[maxn],fa[maxn],zh[maxn];
int d[maxn][maxn],e[maxn];
bool b[maxn];
int n,m,now,tot;
bool goal; void ins(int s ,int f) //创建邻接表
{
now++;
c[now].s=s;
c[now].f=f;
c[now].next=sta[s];
sta[s]=now;
} void bfs()
{
int i,cl,op,k,t;
cl=;op=;
for(i=;i<=n ;i++) fa[i]=;
zh[]=;fa[]=-;
while(cl<op)
{
cl++;
k=zh[cl];
for( t=sta[k] ; t ; t=c[t].next )
if(b[c[t].f]&&fa[c[t].f]==)
{
op++;
zh[op]=c[t].f;
fa[c[t].f]=c[t].s;
if(c[t].f==n) break;
}
if(fa[n]) break ;
}
} void dfs(int deep)
{
int i,cl,op,l,k;
if(goal) return ;
bfs();
if(fa[n]==)
{
goal=true ;
return ;
}
l=;
for(k=n ;k>l ; k=fa[k])
{
l++;
d[deep][l]=k;
}
if(l>m)
{
goal=true;
return ;
}
if(deep>tot) return ; for(i=;i<=l;i++)
{
b[d[deep][i]]=false ;
if(e[d[deep][i]]==) dfs(deep+);
b[d[deep][i]]=true;
e[d[deep][i]]++;
}
for(i= ; i<=l ; i++ )
e[d[deep][i]]--;
} int make()
{
int i,j;
goal= false;
for(i= ;i<=n ;i++)
{
tot=i;
for(j=;j<=n ;j++) b[j]=true;
memset(e,,sizeof(e));
dfs();
if(goal) return i;
}
return n;
} int main()
{
int i,s,f,g;
while()
{
scanf("%d%d%d",&n,&g,&m);
if(n==) break;
memset(sta,,sizeof(sta));
now=;
for(i=; i<=g ;i++)
{
scanf("%d%d",&s,&f);
ins(s,f);
}
g=make();
printf("%d\n",g);
}
return ;
}
 

HDUOJ----2485 Destroying the bus stations(2008北京现场赛A题)的更多相关文章

  1. HDUOJ-------2493Timer(数学 2008北京现场赛H题)

    Timer Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Subm ...

  2. HDUOJ--------A simple stone game(尼姆博弈扩展)(2008北京现场赛A题)

    A simple stone game                                                                                  ...

  3. HDU 2485 Destroying the bus stations(!最大流∩!费用流∩搜索)

    Description Gabiluso is one of the greatest spies in his country. Now he’s trying to complete an “im ...

  4. 图论--网络流--最小割 HDU 2485 Destroying the bus stations(最短路+限流建图)

    Problem Description Gabiluso is one of the greatest spies in his country. Now he's trying to complet ...

  5. HDU 2485 Destroying the bus stations (IDA*+ BFS)

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=2485 题意:给你n个点,m条相连的边,问你最少去掉几个点使从1到n最小路径>=k,其中不能去掉1, ...

  6. HDU 2485 Destroying the bus stations(费用流)

    http://acm.hdu.edu.cn/showproblem.php?pid=2485 题意: 现在要从起点1到终点n,途中有多个车站,每经过一个车站为1时间,现在要在k时间内到达终点,问至少要 ...

  7. HDU 2485 Destroying the bus stations

    2015 ACM / ICPC 北京站 热身赛 C题 #include<cstdio> #include<cstring> #include<cmath> #inc ...

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

    题意: 最少需要几个点才能使得有向图中1->n的距离大于k. 分析: 删除某一点的以后,与它相连的所有边都不存在了,相当于点的容量为1.但是在网络流中我们只能直接限制边的容量.所以需要拆点来完成 ...

  9. hdu-----2491Priest John's Busiest Day(2008 北京现场赛G)

    Priest John's Busiest Day Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Jav ...

随机推荐

  1. mysql中整数类型后面的数字,是不是指定这个字段的长度?比如int(11),11代表11个字节吗?

    原文地址:    http://www.cnblogs.com/stringzero/p/5707467.html 原先对mysql不太理解,但也没有报错.但理解的不够深入.这次补上. 原来以为int ...

  2. cpu,内存,虚拟内存,硬盘,缓存之间是什么关系??

    1.CPU即中央处理器,是英语“Central Processing Unit”的缩写.CPU从内存或缓存中取出指令,放入指令寄存器,并对指令译码分解成一系列的微操作,然后发出各种控制命令,执行微操作 ...

  3. Django的Many-to-Many(多对多)模型

      Django的Many-to-Many(多对多)模型 日期:2012-05-05 |  来源:未知 |  作者:redice |  人围观 |  1 人鼓掌了! 鲲鹏Web数据抓取 - 专业Web ...

  4. servlet&jsp高级:第五部分

    声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...

  5. ios 学习线路(图片)(摘录)

    iOS学习路线

  6. mysql获得自增字段下一个值

    初次研究: 表: sql: show table status from carsale_db LIKE 'tb_car' 结果: 想办法取得这其中的值.... 在Internet上找到这个资料: M ...

  7. FlexSlider插件的详细设置参数 http://www.woothemes.com/flexslider/ -----幻灯片插件

    $(window).load(function() { $('.flexslider').flexslider({ namespace: 'flex-', //控件的命名空间,会影响样式前缀 anim ...

  8. Redis基础知识之————使用技巧(持续更新中.....)

    一.key 设计技巧 把表名转换为key前缀 如, tag: 第2段放置用于区分区key的字段--对应mysql中的主键的列名,如userid 第3段放置主键值,如2,3,4...., a , b , ...

  9. Java中正则Matcher类的matches()、lookAt()和find()的区别<转>

    在Matcher类中有matches.lookingAt和find都是匹配目标的方法,但容易混淆,整理它们的区别如下: matches:整个匹配,只有整个字符序列完全匹配成功,才返回True,否则返回 ...

  10. Linux小知识

    1,ubuntu下,开机如何进行命令行? 图形模式下,首先进入终端: 1. 找到 /etc/default/grub文件: 2. 修改 GRUB_CMDLINE_LINUX_DEFAULT=" ...