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 1112. Cover

Help me!!!!!!!!!!!!!!
Posted by BYF 9 Nov 2002 18:37
Program P1112;
  Type
    Coor=Record
           X,Y:Integer;
         End;
  Var
    N,I,J,Last,Which:Integer;
    Num,Del:Array[1..100] Of Coor;

procedure Sort(l, r: longint);
var
  i, j, x: longint;
  Y:Coor;
begin
  i := l; j := r; x := Num[(l+r) DIV 2].Y;
  repeat
    while Num[i].Y < x do i := i + 1;
    while x < Num[j].Y do j := j - 1;
    if i <= j then
    begin
      y := Num[i]; Num[i] := Num[j]; Num[j] := y;
      i := i + 1; j := j - 1;
    end;
  until i > j;
  if l < j then Sort(l, j);
  if i < r then Sort(i, r);
end;

  Begin
    Readln(N);
    For I:=1 To N Do
      Begin
        Readln(Num[I].X,Num[I].Y);
        If Num[I].X>Num[I].Y Then
          Begin J:=Num[I].X; Num[I].X:=Num[I].Y; Num[I].Y:=J; End;
      End;
    Sort(1,N);
    I:=0;
    Last:=0;
    Which:=0;
    Repeat
      Inc(I);
      If Num[I].X>=Last Then
        Begin Inc(Which); Last:=Num[I].Y; Del[Which]:=Num[I]; End;
    Until I=N;
    Writeln(Which);
    For I:=1 To Which Do Writeln(Del[I].X,' ',Del[I].Y);
  End.
Sorry, I found I made a big mistake, and now I get AC!!!
Posted by BYF 9 Nov 2002 18:43