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 1303. Minimal Coverage

Where i'm wrong?
Posted by test_programs 11 May 2004 22:07
my source:
type TOtr = record
                  l: longint;
                  r: longint;
            end;
var  M,j: longint;
     Otr: TOtr;
     Buf: TOtr;
     Res: array[1..100000] of TOtr;
     i:   longint;
function IsOtr(o1,o2: TOtr): boolean; {o1 in o2}
begin
     isotr:=(o1.l>=o2.l) and (o1.l<=o2.r) and (o1.r<=o2.r) and (o1.r>=o2.l);
end;
procedure Sort(var o: TOtr);
var i: longint;
begin
     if o.l>o.r then
        begin
             i:=o.l;
             o.l:=o.r;
             o.r:=i;
        end;
end;
begin
     readln(m);
     Buf.l:=0;
     Buf.r:=m;
     readln(otr.l,otr.r);
     j:=0;
     if otr.l>otr.r then sort(otr);
     repeat
           if isotr(otr,buf) then
              begin
                   inc(j);
                   res[j]:=otr;
              end;
           readln(otr.l,otr.r);
     until (otr.l=0) and (otr.r=0);
     if j > 0 then
        begin
             writeln(j);
             for i:=1 to j do
                 writeln(res[i].l,' ',res[i].r);
        end
     else
         writeln('No solution');
end.
i get WA on 3rd test.
but why?
Re: Where i'm wrong?
Posted by +FAMAS+ 7 Jan 2006 23:09
procedure sort; - wrong
3
0 1
2 3
1 2
0 0
:( wrong answer