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 1203. Scientific Conference

Why i got WA?Please help(Code inside)
Posted by Ural_Huang Shang 12 Feb 2003 18:56
program p1203t;
const maxt=30000;
type arr1=array [0..maxt] of integer;
     rec=record ts,te:integer; end;
     arr2=array [0..maxt] of rec;
var a:arr1; n:integer; con:arr2;

{$APPTYPE CONSOLE}

procedure init;
var i,ts,te,j,k:integer; t:arr1;
begin
     readln(n); fillchar(t,sizeof(t),0); j:=0;
     for i:=1 to n do
       begin
         readln(ts,te);
         if (ts>te) then begin k:=ts; ts:=te; te:=k; end;
         if (ts=0) then ts:=-1;
         if (t[te]<ts) then t[te]:=ts;
       end;
     for i:=0 to maxt do
       if (t[i]<>0) then
         begin
           inc(j);
           if (t[i]=-1) then t[i]:=0;
           con[j].ts:=t[i]; con[j].te:=i;
         end;
     for i:=0 to maxt do a[i]:=0; n:=j;
end;

procedure solve;
var i,j:integer;
begin
     for i:=1 to n do
       begin
         for j:=(con[i-1].te+1) to con[i].te do a[j]:=a[con[i-1].te];
         if (a[con[i].ts-1]+1>a[con[i].te]) then a[con[i].te]:=a[con
[i].ts-1]+1;
       end;
end;

procedure sout;
begin
     writeln(a[con[n].te]);
end;

begin
     init;
     solve;
     sout;
end.