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

Common Board

Help.... 1235 is here??? http://neerc.ifmo.ru/Regional/problems/cricket.htm
Posted by Locomotive 21 Feb 2003 12:02
Should we read from file 'cricket.in' or something else???
what about output?
why i got wa?

Type
  Point               = Record
    x,y               : Integer;
  End;
  byte=integer;
Var
  N,I,J,K,R,RR        : Byte;
  W,H                 : Integer;
  Ans                 : Point;
  a,b,c               : array[0..100]of Integer;
  Tree                : array[1..100] of point;
f:text;
Function Part(first,last:Byte):Byte;
Var
  i,j                 : byte;
  x,t                 : integer;
begin
  i:=first-1; j:=last+1; x:=c[first];
  repeat
    repeat inc(i);
    until c[i]>=x;
    repeat dec(j);
    until c[j]<=x;
    if i<j then
      begin t:=c[i]; c[i]:=c[j]; c[j]:=t; end
    else
      begin part:=j; exit; end;
  until false;
End;

Procedure Sort(first,last:integer);
Var
  w                   : Integer;
Begin
  If First<last then
  begin
    w:=part(first,last);
    sort(first,w);
    sort(w+1,last);
  end;
End;

Function Min(x,y:integer):integer;
Begin
  if x<y then
    min:=x
  else
    min:=y;
end;

begin
assign(f,'cricket.in'); reset(f);
  ReadLn(f,N,W,H);
  For i:=1 to N do
  Begin
    Readln(f,Tree[i].x,tree[i].y);
    Inc(A[0]); a[a[0]]:=tree[i].x;
    inc(b[0]); b[b[0]]:=tree[i].y;
  End;
close(f);
  c:=a; sort(1,c[0]);
  a[0]:=1; a[1]:=c[1];
  for i:=2 to c[0] do
    if c[i]<>c[i-1] then
      begin inc(a[0]); a[a[0]]:=c[i]; end;
  c:=b; sort(1,c[0]);
  b[0]:=1; b[1]:=c[1];
  for i:=2 to c[0] do
    if c[i]<>c[i-1] then
      begin inc(b[0]); b[b[0]]:=c[i]; end;
  RR:=0;
  For i:=1 to a[0] do
    For j:=1 to b[0] do
    begin
      R:=min(W-a[i],H-B[j]);
      For k:=1 to N do
        if (tree[k].x>a[i]) and (tree[k].y>b[j]) then
        begin
          R:=min(R,tree[k].x-a[i]);
          R:=min(R,tree[k].y-B[j]);
        end;
      If R>RR then
        begin RR:=r; ans.x:=a[i]; ans.y:=b[j]; end;
    end;
assign(f,'cricket.out'); rewrite(f);
  writeln(f,ans.x,' ',ans.y,' ',RR);
close(f);
end.
Re: Help.... 1235 is here??? http://neerc.ifmo.ru/Regional/problems/cricket.htm
Posted by Marcin Mika 21 Feb 2003 12:23
> Should we read from file 'cricket.in' or something else???
> what about output?
input is from standard input as usual.
output to standard output also.
don't read from any files