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 1288. Astrolocation

const
  eps=0;
var
  b:array[1..10000] of extended;
  n,d,s1,e1,s2,e2:integer;
  l1,l2:extended;
  a:extended;
  i,f,back:integer;
  frontsearch,frontfound,backsearch,backfound:Boolean;
procedure SearchForFrontWall;
var
  i:integer;
begin
  i:=0;
  frontsearch:=false;
  frontfound:=false;
  repeat
    inc(i);
    frontsearch:=b[i]-35<=eps
  until (i=n) or frontsearch;
  if frontsearch then
    begin
      repeat
        inc(i);
        frontfound:=b[i]-95>=eps
      until (i=n) or frontfound;
      if frontfound then
        begin
          f:=i;
          writeln('Surface found at ',f,'.')
        end
    end
end;
procedure SearchForBackWall;
var
  i:integer;
begin
  i:=f;
  backsearch:=false;
  backfound:=false;
  repeat
    inc(i);
    backsearch:=b[i]-35<=eps
  until (i=n) or backsearch;
  if backsearch then
    begin
      if i<f+d-1 then
        i:=f+d-1;
      repeat
        inc(i);
        backfound:=b[i]-95>=eps
      until (i=n) or backfound
    end;
  if backfound then
    begin
      back:=i-f;
      writeln('Bottom found at ',back,'.')
    end
  else
    begin
      writeln('No bottom.');
      back:=n-f+1
    end;
end;
procedure SearchChannel(num,s,e:integer;l:extended);
var
  i,m:integer;
begin
  if s>=back then
    writeln('Channel ',num,': No search.')
  else
    begin
      m:=s;
      if e>=back then
        e:=back-1;
      for i:=s+1 to e do
        if b[i+f]-b[m+f]>eps then
          m:=i;
      if b[m+f]-l>eps then
        writeln('Channel ',num,': Object at ',m,'.')
      else
        writeln('Channel ',num,': No object.')
    end
end;
begin
  readln(n,d,s1,e1,l1,s2,e2,l2,a);
  for i:=1 to n do
    readln(b[i]);
  SearchForFrontWall;
  if frontfound then
    begin
      for i:=f+1 to n do
        b[i]:=b[i]*(1+(i-f)*a);
      SearchForBackWall;
      SearchChannel(1,s1,e1,l1);
      SearchChannel(2,s2,e2,l2)
    end
  else
    writeln('No surface.')
end.
Victor Barinov (TNU) Try this test: [2] // Problem 1288. Astrolocation 10 Oct 2004 16:11
8 0 3 6 72 7 7 22 0.008000
97
19
91
66
65
24
52
96

my AC program outputs:

Surface found at 8.
No bottom.
Channel 1: No search.
Channel 2: No search.
Danica Porobic Re: Try this test: [1] // Problem 1288. Astrolocation 24 Aug 2005 03:16
Thanks for the test, but I still can't turn it into AC: if I replace extended with either real or double I get WA #5. And my program evaluates your test case correctly after just one small fix for all those real types!

Can someone please help me?
Denis Koshman Re: Try this test: // Problem 1288. Astrolocation 20 Aug 2008 21:38
If FRONT+D >N, you're in trouble because of "until(i=n)". I had same problem in my C++ solution, but it was WA5 :)