bus

Description
Gabiluso是最伟大的间谍之一。现在,他试图完成一个“不可能完成”的使命――减缓Colugu的军队到达机场的时间。Colugu有n个公共汽车站和m条道路。每条道路直接连接两个巴士站,所有的道路都是单向的。为了保持空气洁净,政府禁止所有军用车辆,因此,军队必须乘搭巴士去机场。两个巴士站之间,可能有超过一条道路。如果一个公共汽车站被破坏时,所有连接该站的道路将无法运作。Gabiluso需要做的是摧毁了一些公共汽车站,使军队无法在K分钟内到达机场。一辆公交车通过一条道路,都是一分钟。所有巴士站的编号从1到n。1号巴士站是在军营,第n号站是机场。军队始终从第一站出发。第一站和第n站不能被破坏,这里有大量的防御力量。当然也没有从第一站到第n站的道路。

请帮助Gabiluso来计算能完成使命所需摧毁的最低数目的巴士站。
Input
第一行包含三个整数n,m,k (2<n<=50,0<m<=4000,0<k<1000)。

接下来m行,每行2个整数s和f,表示从站s到站f有一条路。
Output
输出最少需要摧毁的巴士站数目。
Sample Input
5 7 3 


1 3 


3 4 


4 5 


1 2 


2 5 


1 4 


4 5
Sample Output
2
Data Constraint

30%的数据N<=15。

var
        a,b,c,d,i,j,time,q3,q1,q2:longint;
        w:array[0..51,0..51]of longint;
        bz:array[0..51]of boolean;
        hand,mid:array[0..101]of longint;
        f:array[0..101,1..2] of longint;
procedure pd;
begin
        while q1<q2 do
        begin
                inc(q1);
                for i:=1 to a do
                        if(mid[i]<>q3)and(bz[i]=false)and(w[f[q1,1],i]=1)then
                        begin
                                mid[i]:=q3;
                                inc(q2);
                                f[q2,1]:=i;
                                f[q2,2]:=f[q1,2]+1;
                                hand[i]:=f[q1,1];
                                if i=a then
                                begin
                                        time:=f[q2,2];
                                        exit;
                                end;
                        end;
        end;
end;
procedure ss(s:longint);
var
        last:array[0..101]of longint;
        i1,t:longint;
begin
        if s=d then
        begin
                begin
                        q1:=0;
                        q2:=1;
                        f[1,1]:=1;
                        inc(q3);
                        mid[1]:=q3;
                        time:=maxlongint;
                end;
                pd;
                if time>c then
                begin
                        writeln(d);
                        halt;
                end;
        end
                else
        begin
                begin
                        q1:=0;
                        q2:=1;
                        f[1,1]:=1;
                        inc(q3);
                        mid[1]:=q3;
                        time:=maxlongint;
                end;
                pd;
                last[1]:=hand[a];
                for i1:=2 to time-1 do
                        last[i1]:=hand[last[i1-1]];
                for i1:=1 to time-1 do
                begin
                        if (bz[last[i1]]=false) then
                        begin
                                bz[last[i1]]:=true;
                                ss(s+1);
                                bz[last[i1]]:=false;
                        end;
                end;
        end;
end;
begin
        assign(input,'bus.in');reset(input);
        assign(output,'bus.out');rewrite(output);
        readln(a,b,c);
        for d:=1 to b do
        begin
                readln(i,j);
                w[i,j]:=1;
        end;
        for d:=0 to a-2 do
                ss(0);
        close(input);
        close(output);
end.



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值