Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

汗……RUNTIME ERROR怎么回事?自家电脑上好好的啊……

Posted by kyd at 2009-06-07 18:28:11 on Problem 3625
program poj3625_road;
var
  v:array [1..1000] of real;
  map:array [1..1000,1..1000] of real;
  pnt:array [1..1000,1..2] of longint;
  i,j,k:longint;
  p:array [1..1000] of boolean;
  min,cost:real;
  minn,n,m:longint;
function dist(x1,y1,x2,y2:longint):real;
       begin
           dist:=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
       end;
begin
    fillchar(p,sizeof(p),false);
    fillchar(pnt,sizeof(pnt),0);
    readln(n,m);
    for i:=1 to n do
      readln(pnt[i,1],pnt[i,2]);
    for i:=1 to n do
      for j:=1 to n do
        if i<>j then map[i,j]:=dist(pnt[i,1],pnt[i,2],pnt[j,1],pnt[j,2]) else map[i,j]:=2000000;
    for i:=1 to m do
      begin
          readln(j,k);
          map[j,k]:=0;
          map[k,j]:=0;
      end;
    v:=map[1];
    p[1]:=true;
    min:=2000000;
    cost:=0;
    for i:=2 to n do
      begin
          min:=2000000;
          for j:=1 to n do
            if (p[j]=false) and (min>v[j]) then begin min:=v[j];minn:=j; end;
          v[minn]:=2000000;
          for j:=1 to n do
            if (map[minn,j]<v[j]) and (p[j]=false) then v[j]:=map[minn,j];
          p[minn]:=true;
          cost:=cost+min;
      end;
    writeln(cost:2:2);
end.







Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator