ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1168. Radio Stations

why I get WA?
Posted by chineseboy 1 Jul 2002 13:58
const inp='';
type fff=record
          x,y:integer;
          r:real;
         end;
var
 map:array[1..50,1..50]of integer;
 fsz:array[1..1000]of fff;
 z:array[1..1000,1..2]of integer;
 n,m,max,k:integer;
 t:text;

procedure zl;
 var i,j:longint;
  begin
   fillchar(map,sizeof(map),0);
   fillchar(z,sizeof(z),0);
   fillchar(fsz,sizeof(fsz),0);
   assign(t,inp);
   reset(t);
   readln(t,m,n,k);
   for i:=1 to m do
    for j:=1 to n do
     read(t,map[i,j]);
   for i:=1 to k do readln(t,fsz[i].x,fsz[i].y,fsz[i].r);
   close(t);
  end;

procedure gc;
 var i,j,l,min,big:longint;
     s:real;
     yes:boolean;
 begin
  for i:=1 to m do
   for j:=1 to n do
    begin
     fillchar(z,sizeof(z),0);
     yes:=true;
     for l:=1 to k do
      if (fsz[l].x<>i)or(fsz[l].y<>j) then
      begin
       s:=sqr(fsz[l].r)-sqr(i-fsz[l].x)-sqr(j-fsz[l].y);
       if s>=0 then
       begin
        z[l,1]:=round(-sqrt(s)+map[fsz[l].x,fsz[l].y]+0.49);
        z[l,2]:=trunc(sqrt(s)+map[fsz[l].x,fsz[l].y]);
        if z[l,1]<map[i,j] then z[l,1]:=map[i,j];
        if z[l,2]<map[i,j] then begin
                                 yes:=false;
                                 break;
                                end
       end else begin
                 yes:=false;
                 break;
                end;
      end
     else begin
           yes:=false;
           break;
          end;
     if yes then
     begin
      min:=z[1,1];big:=z[1,2];
      for l:=2 to k do
      begin
       if min<z[l,1] then min:=z[l,1];
       if big>z[l,2] then big:=z[l,2];
      end;
      if (big>=min)and yes then max:=max+(big-min)+1;
     end;
   end;
 end;

begin
 zl;
 gc;
 writeln(max);
end.
please tell me why?