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!!!

Posted by haiwei623 at 2009-08-05 11:49:37 on Problem 1258
program pku1258;
var n,i,j,k,min,m,d,s,o:longint;
    a:array[1..100,1..100]of longint;
    b:array[1..100,1..3]of longint;
    t:array[1..3]of longint;
begin
  while not(eof)do
  begin
    read(n);
    s:=0;
    fillchar(a,sizeof(a),0);
    fillchar(b,sizeof(b),0);
    for i:=1 to n do
    begin
      for j:=1 to n do
      begin
        read(a[i,j]);
        if a[i,j]=0 then a[i,j]:=maxlongint;
      end;
    end;
    for i:=1 to n-1 do
    begin
      b[i,1]:=1;
      b[i,2]:=i+1;
      b[i,3]:=a[1,i+1];
    end;
    for k:=1 to n-1 do
    begin
      min:=maxlongint;
      m:=k;
      for j:=k to n-1 do
      if b[j,3]<min then
      begin
        min:=b[j,3];
        m:=j;
      end;
      s:=s+min;
      if k<>m then
      begin
        t:=b[k];
        b[k]:=b[m];
        b[m]:=t;
      end;
      j:=b[k,2];
      for i:=k+1 to n-1 do
      begin
        d:=b[i,2];
        o:=a[d,j];
        if o<b[i,3] then
        begin
          b[i,1]:=j;
          b[i,3]:=o;
        end;
      end;
    end;
    writeln(s);
  end;
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