| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
已AC,原来是total没有初始化In Reply To:当年在USACO上面AC的程序,已经改成了多CASE了,为什么WA啊? Posted by:galaxy at 2006-03-06 02:07:23 > program agrinet;
> type node=record
> data:longint;
> f:longint;
> r:longint;
> end;
>
> var c:array [1..100,1..100] of longint;
> a:array [1..100] of node;
> b:node;
> i,j,n,q,p,min,f,r,total:longint;
>
> begin
> {assign(input,'agrinet.in');
> reset(input);
> assign(output,'agrinet.out');
> rewrite(output);}
> while (not eof) do
> begin
> readln(n);
> for i:=1 to n do
> begin
> for j:=1 to n do
> read(c[i,j]);
> readln;
> end;
>
> for i:=1 to n-1 do
> begin
> a[i].f:=1;
> a[i].r:=i+1;
> a[i].data:=c[1,i+1];
> end;
>
>
> for i:=1 to n-2 do
> begin
> min:=maxlongint;
> for j:=i to n-1 do
> if a[j].data<min then
> begin
> min:=a[j].data;
> p:=j;
> f:=a[j].r;
> end;
> b:=a[p];a[p]:=a[i];a[i]:=b;
> for q:=i+1 to n-1 do
> if c[a[i].r,a[q].r]<a[q].data then
> begin
> a[q].f:=a[i].r;
> a[q].data:=c[a[i].r,a[q].r];
> end;
> end;
> for i:=1 to n-1 do
> inc(total,a[i].data);
> writeln(total);
> end;
> end.
>
>
>
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator