|
|
back to boardWhere i'm wrong? 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? procedure sort; - wrong 3 0 1 2 3 1 2 0 0 :( wrong answer |
|
|