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 1111. Squares

What happen if the problem change Squares to Rectangle, I have submit this code and i got WA ,I heard that it's different from the rectangle, what about it???
Posted by Badd 10 Jan 2002 09:23
     for loop:=1 to n do
         begin
              if px in [dat[loop].x1..dat[loop].x2] then
                 begin
                   if py in [dat[loop].y1..dat[loop].y2] then
                    begin dat[loop].nearx:=px; dat[loop].neary:=py; end
                   else
                   if py<dat[loop].y1 then
                    begin dat[loop].nearx:=px; dat[loop].neary:=dat[loop].y1; end
                   else
                   if py>dat[loop].y2 then
                    begin dat[loop].nearx:=px; dat[loop].neary:=dat[loop].y2; end;
                 end
              else
              if py in [dat[loop].y1..dat[loop].y2] then
                 begin
                   if px<dat[loop].x1 then
                      begin dat[loop].neary:=py; dat[loop].nearx:=dat[loop].x1; end
                   else
                   if px>dat[loop].x2 then
                      begin dat[loop].neary:=py; dat[loop].nearx:=dat[loop].x2;
end;
                 end
              else
              if py<dat[loop].y1 then
                 begin
                      if px<dat[loop].x1 then begin dat[loop].nearx:=dat[loop].x1;
dat[loop].neary:=dat[loop].y1; end
                      else
                      if px>dat[loop].x2 then begin dat[loop].nearx:=dat[loop].x2;
dat[loop].neary:=dat[loop].y1; end
                 end
              else
              if py>dat[loop].y2 then
                  begin
                       if px<dat[loop].x1 then begin dat[loop].nearx:=dat[loop].x1;
dat[loop].neary:=dat[loop].y2; end
                       else
                       if px>dat[loop].x2 then begin dat[loop].nearx:=dat[loop].x2;
dat[loop].neary:=dat[loop].y2; end
                  end;
         end;

and then i check the distance from each dat[i].nearx,neary to point
The square could have these coordinates : (0,0), (1,1), (0,2), (-1,1). Good luck! (-)
Posted by shitty.Mishka 10 Jan 2002 13:06