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

大佬帮忙 wa啦 free pascal

Posted by zhangsheng10 at 2017-07-14 14:41:03 on Problem 1258
program p1258(input,output);
var
  v:array[1..100] of boolean;
  a:array[1..100,1..100] of longint;
  ans,n,i,j,k,p,q,d:longint;
begin
  readln(n);
  for i:=1 to n do
    begin
      for j:=1 to n do
        read(a[i,j]);
      readln;
    end;
  fillchar(v,sizeof(v),false);
  i:=0;j:=0;d:=maxlongint;
  for i:=1 to n-1 do
    for j:=i+1 to n do
      if a[i,j]<d then
        begin
          d:=a[i,j];p:=i;q:=j;
        end;
  ans:=d;
  v[p]:=true;
  v[q]:=true;
  for i:=3 to n do
    begin
      p:=0;
      d:=maxlongint;
      for j:=1 to n do if not v[j] then
        for k:=1 to n do if v[k] and (a[j,k]<d) then
          begin
            d:=a[j,k];
            p:=j;
          end;
      ans:=ans+d;
      v[p]:=true;
    end;
  writeln(ans);
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