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 1097. Square Country 2

Why I got wa?Help!
Posted by lingwei 12 Oct 2002 19:10
Here is my code:
{$r-,s-,q-}

type
 owner=record
        x,y,le:integer;
        import:byte;
       end;
var
 member:array[1..100] of owner;
 n,l,m:integer;

procedure init;
 var
  i:integer;
 begin
  fillchar(member,sizeof(member),0);
  read(n,l);
  read(m);
  for i:=1 to m do
   with member[i] do read(import,le,x,y);
 end;

function touch(x1,x2,y1,y2,x3,x4,y3,y4:integer):boolean;
 begin
  if (((x1>x4) or (x2<x3)) or ((y1>y4) or (y2<y3))) and
     (not ((x1>=x3) and (x2<=x4) and (y1>=y3) and (y2<=y4))) and
     (not ((x3>=x1) and (x4<=x2) and (y3>=y1) and (y4<=y2))) then
   touch:=false
    else
    touch:=true;
 end;

procedure solve;
 var
  i,j,k:integer;
  max,min:byte;
  x1,x2,x3,x4,y1,y2,y3,y4:integer;
  t:boolean;
 begin
  min:=255;
  for i:=1 to n-l+1 do
   for j:=1 to n-l+1 do
    begin
     max:=0;
     x1:=j;x2:=j+l-1;
     y1:=i;y2:=i+l-1;
     for k:=1 to m do
      with member[k] do
      begin
       x3:=x;x4:=x+le-1;
       y3:=y;y4:=y+le-1;
       t:=touch(x1,x2,y1,y2,x3,x4,y3,y4);
       if t and (import>max) then max:=import;
       if max>min then break;
      end;
     if max<min then min:=max;
    end;
  if min<=100 then writeln(min)
   else writeln('IMPOSSIBLE');
 end;

begin
 init;
 solve;
end.
Change "max:=0" to "max:=1" and you'll get TL :(
Posted by Dmitry 'Diman_YES' Kovalioff 3 Dec 2002 15:17