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

Re:我去,floyd竟然0ms,更诡异的是我数组开10*10竟然AC了!

Posted by chenwenxiao at 2011-07-30 09:38:17 on Problem 1125
In Reply To:我去,floyd竟然0ms,更诡异的是我数组开10*10竟然AC了! Posted by:huangzhilv at 2011-06-06 15:30:41
> 以下是诡异代码
> 忘记改数组大小竟然AC了!而且是0ms
> 改了100*100就32ms了……
> 
> program poj1125;
> const
>   maxn=10;//这太神奇了
>   maxlongint=1000000;
> 
> var
>   a:array[1..maxn,1..maxn] of longint;
>   n,i,j,d,x,y,max,min,mini:longint;
> 
> procedure floyd;
> var
>   i,j,k:longint;
> begin
>   for k:=1 to n do
>   for i:=1 to n do
>   for j:=1 to n do
>   if (a[i,k]+a[k,j]<a[i,j]) then a[i,j]:=a[i,k]+a[k,j];
> end;
> 
> begin
>   readln(n);
>   while n<>0 do
>   begin
>   fillchar(a,sizeof(a),0);
> 
>   for i:=1 to n do
>   for j:=1 to n do
>     if (i<>j) then a[i,j]:=maxlongint
>               else a[i,j]:=0;
> 
>   for i:=1 to n do
>   begin
>     read(d);
> 
>     for j:=1 to d do
>     begin
>       read(x,y);
>       a[i,x]:=y;
>     end;
>   end;
> 
>   floyd;
> 
>   min:=maxlongint; mini:=0;
>   for i:=1 to n do
>   begin
>     max:=0;
>     for j:=1 to n do
>       if a[i,j]>max then max:=a[i,j];
> 
>     if (max<>maxlongint) and (max<min) then
>     begin
>       min:=max; mini:=i;
>     end;
>   end;
>   if min<>maxlongint then
>     writeln(mini,' ',min)
>   else
>     writeln('disjoint');
> 
>   readln(n);
>   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