武汉二中信息组吧 关注:13贴子:632
  • 12回复贴,共1

【求助】_(:3√∠)_我已经不行了、、、血流成河啊、、、

只看楼主收藏回复

一楼JUST WE 求不要毁我格式


1楼2012-08-02 11:44回复
    program tyvj1609;
    type node=record
    y,next,w:longint;
    end;
    var
    n,m,u,v,time,i,tot,x,y,z,max:longint;
    a,f,p,q,dist:array[1..10000]of longint;
    flag:array[1..10000]of boolean;
    g:array[1..100000]of node;
    procedure up(l:longint);
    var x,xp:longint;
    begin x:=dist[p[l]];
    xp:=p[l];
    while l div 2>=1 do
    begin
    if dist[p[l div 2 ]]>x then
    begin
    p[l]:=p[l div 2];
    q[p[l]]:=l;
    l:=l div 2;
    end
    else break;
    end;
    p[l]:=xp;
    q[p[l]]:=l;
    end;
    procedure down(l,n:longint);
    var
    j,x,xp:longint;
    begin j:=l*2;
    x:=dist[p[l]];
    xp:=p[l];
    while j<=n do
    begin
    if (dist[p[j]]>dist[p[j+1]]) and (j<n) then inc(j);
    if dist[p[j]]<x then
    begin
    p[l]:=p[j];
    q[p[l]]:=l;
    l:=j;
    j:=j*2;
    end
    else break;
    end;
    p[l]:=xp;
    q[p[l]]:=l;
    end;
    function dijkstra(x:longint):boolean;
    var
    j,t,m,k:longint;
    begin
    for j:=1 to n do
    dist[j]:=maxlongint;
    dist[u]:=0;
    fillchar(q,sizeof(q),0);
    fillchar(p,sizeof(p),0);
    fillchar(flag,sizeof(flag),0);
    m:=0;
    t:=f[u];
    flag[u]:=true;
    while t<>0 do
    begin
    if a[g[t].y]<=x then
    begin
    dist[g[t].y]:=g[t].w;
    inc(m);
    p[m]:=g[t].y;
    q[p[m]]:=m;
    end;
    t:=g[t].next;
    end;
    for j:=m div 2 downto 1 do
    down(j,m);
    while m>0 do
    begin
    k:=p[1];
    flag[k]:=true;
    p[1]:=p[m];
    q[p[1]]:=1;
    dec(m);
    down(1,m);
    t:=f[k];
    while t<>0 do
    begin
    if a[g[t].y]<=x then
    begin
    if (dist[g[t].y]>dist[k]+g[t].w) and (not flag[g[t].y]) then
    begin
    dist[g[t].y]:=dist[k]+g[t].w;
    if q[g[t].y]=0 then
    begin
    inc(m);
    p[m]:=g[t].y;
    q[p[m]]:=m;
    end;
    up(q[g[t].y]);
    end;
    end;
    t:=g[t].next;
    end;
    end;
    if dist[v]<=time then
    exit(true)
    else exit(false);
    end;
    procedure dichotomy(l,r:longint);
    var
    m:longint;
    begin
    while l<r do
    begin
    m:=l+(r-l) div 2;
    if dijkstra(m) then
    begin
    r:=m;
    end
    else
    l:=m+1;
    end;
    if dijkstra(l) then
    writeln(l)
    else
    writeln(-1);
    end;
    begin
    assign(input,'1609.in');reset(input);
    assign(output,'1609.out');rewrite(output);
    readln(n,m,u,v,time);
    tot:=0;
    max:=0;
    for i:=1 to n do
    begin
    read(a[i]);
    if a[i]>max then
    max:=a[i];
    end;
    for i:=1 to m do
    begin
    read(x,y,z);
    inc(tot);
    g[tot].y:=y;
    g[tot].w:=z;
    g[tot].next:=f[x];
    f[x]:=tot;
    inc(tot);
    g[tot].y:=x;
    g[tot].w:=z;
    g[tot].next:=f[y];
    f[y]:=tot;
    end;
    dichotomy(a[u],max+1);
    close(input);close(output);
    end.
    


    2楼2012-08-02 12:01
    回复
      还是把我的格式毁了、、、求挑错、、、


      3楼2012-08-02 12:02
      回复
        第一遍写完此题:
        第一遍评测此题:
        第二遍改完此题:
        第二遍评测此题:
        第三遍改完此题:
        第三遍评测此题:
        第四遍差错中:……
        第五遍差错中:……
        第六遍差错中:……
        第七遍差错中:……
        我瞎了……
        然后……然后就没有然后了……


        4楼2012-08-02 15:35
        回复
          可以的话悬赏百度知道100分、、、【抹抹血


          5楼2012-08-02 15:39
          回复
            ...


            6楼2012-08-03 08:46
            回复
              咦?今天大家也有欢快地发水贴吗?


              7楼2012-08-03 21:15
              收起回复

                哟呼呼呼呼呼~~~~~~~~~~~~~~~~~~~此题已过~开心的刘明!


                8楼2012-08-10 21:38
                回复