# 尾声-怪盗基德的逃离

怪盗基德第四次拿着战利品信心满满地离开了OIBH总部，一路上大摇大摆，好不

ing...

描述 Description

果然，基德的撤退路上被布置一个巨大的迷宫。这迷宫是一个巨大的道路网，每

n号结点是出口。现在要求你在规定时间内，花去尽可能多的钱（据说不这样做就

输入格式 Input Format

第一行4个整数n,m,t,v，分别是结点总数，通路总数，规定时间，及基德所拥有

输出格式 Output Format

输出共2个整数t2,v2，分别表示用时和所剩钱数。你要保证t2<=tv2>=0

8 10 10 120

1 2 2 1

1 3 1 1

1 4 2 19

2 3 2 6

3 4 1 1

3 5 2 2

5 6 2 1

6 7 1 3

7 8 3 1

4 8 7 100

9 1

2<=n<=100
1<=t,v<=500

代码一：program li;
type node=record
t,s,h:integer;
end;
var
z:array[1..1000,1..1000]of node;
i,j,n,m,xs,hf,a,b,c,d,shi,money:integer;
max,min:integer;
y:array[1..1000]of boolean;

procedure print;
begin
writeln(min:5,hf-max:5);
end;

procedure dfs(i,shi,money:integer);
var j:integer;
begin
for j:=1 to n do
if (z[i,j].t=1){and(y[j]=false)} then begin
z[i,j].t:=0;z[j,i].t:=0; shi:=shi+z[i,j].s;money:=money+z[i,j].h; //y[j]:=true;
if (j<>n)and (shi<xs)and(hf-money>=0) then dfs(j,shi,money);
if (j=n)and (shi<xs)and(hf-money>=0) then begin
if (money>max)or(money=max)and(shi<min) then
begin
min:=shi;max:=money;
end;
end;
z[i,j].t:=1;z[j,i].t:=1;shi:=shi-z[i,j].s;money:=money-z[i,j].h;//y[j]:=false;
end;end;
begin
assign(input,'input.txt');
assign(output,'output.txt');
reset(input);
rewrite(output);
for i:=1 to m do
begin
z[a,b].t:=1;z[b,a].t:=1;
z[a,b].s:=c;z[b,a].s:=c;
z[a,b].h:=d;z[b,a].h:=d;
end;
fillchar(y,sizeof(y),0);
min:=32767; max:=0;y[1]:=true;dfs(1,0,0); print;
close(input);close(output);
end.

xx=record
d,t,v:integer;
nu:longint;
end;
var
b:array[1..10000]of boolean;
a:array[1..100]of integer;
w:array[1..100,1..100]of xx;
i,j,k,m,n,t,v,h,l:longint;
ans,sum:longint;
procedure find(h,tt,vv:longint);
var
i,j:integer;
begin
if h=n then begin
if (vv>ans)or((vv=ans)and(tt<sum)) then begin
ans:=vv;
sum:=tt;
end;
exit;
end;
for i:=1 to a[h] do
if not b[w[h,i].nu] then
if (tt+w[h,i].t<=t)and(vv+w[h,i].v<=v) then begin
b[w[h,i].nu]:=true;
find(w[h,i].d,tt+w[h,i].t,vv+w[h,i].v);
b[w[h,i].nu]:=false;
end;
end;
begin
assign(input,'input.txt');
assign(output,'output.txt');
reset(input);
rewrite(output);
for i:=1 to m do begin
inc(a[j]);
inc(a[k]);
w[j,a[j]].d:=k;
w[j,a[j]].t:=h;
w[j,a[j]].v:=l;
w[j,a[j]].nu:=i;
w[k,a[k]].d:=j;
w[k,a[k]].t:=h;
w[k,a[k]].v:=l;
w[k,a[k]].nu:=i;
end;
fillchar(b,sizeof(b),0);
sum:=10000;
find(1,0,0);
writeln(sum,' ',v-ans);
close(input);close(output);
end.

#### 怪盗基德的滑翔翼

2015-07-26 17:42:04

#### openjudge 怪盗基德的滑翔翼

2015-12-02 19:09:49

#### 【NOI OJ】4977 怪盗基德的滑翔翼

2016-10-01 13:20:23

#### OpenJudge_P4977 怪盗基德的滑翔翼(DP)

2015-12-05 21:05:49

#### Openjudge4977 怪盗基德的滑翔翼(dp)

2015-08-05 17:21:24

#### T1286 怪盗基德的滑翔翼（#Ⅱ- 9 - 1）

2018-06-01 20:34:14

#### 动态规划练习一 14:怪盗基德的滑翔翼

2017-04-14 09:35:33

#### 2017北大信科夏令营机试E：怪盗基德的滑翔翼

2017-08-22 15:11:35

#### 北京大学ACM/ICPC竞赛训练暑期课练习之怪盗基德的滑翔翼

2015-07-23 10:58:08

#### 动态规划练习14:怪盗基德的滑翔翼

2017-04-19 16:44:03