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 1078. Segments

Why I am WA.
Posted by ufx 12 May 2003 06:14
program t1078;
const
  maxn=500;
type
  tnode=record
    x,y:integer;
  end;
var
  p:array[1..maxn] of tnode;
  v:array[1..maxn] of integer;
  f:array[1..maxn] of integer;
  pre:array[1..maxn] of integer;
  n,i,j:integer;

procedure init;
var
  i,j,y:integer;
  x:tnode;
begin
  for i:=1 to n do v[i]:=i;
  for i:=1 to n do
   for j:=i+1 to n do
    if p[i].y>p[j].y then begin
       x:=p[i];
       p[i]:=p[j];
       p[j]:=x;
       y:=v[i];
       v[i]:=v[j];
       v[j]:=y;
    end;
end;

procedure dynamic;
var
  i,j,k:integer;

  procedure outans(i:integer);
  begin
    if i<>0 then begin
       outans(pre[i]);
       write(v[i],' ');
    end;
  end;
begin
  fillchar(f,sizeof(f),0);
  fillchar(pre,sizeof(pre),0);
  f[1]:=1;pre[1]:=0;
  for i:=2 to n do
   for j:=1 to i-1 do
    if (p[j].x>p[i].x) and (f[j]+1>f[i]) then begin
       f[i]:=f[j]+1;
       pre[i]:=j;
    end;
  j:=1;k:=f[1];
  for i:=2 to n do if k<f[i] then begin
      k:=f[i];
      j:=i;
  end;
  writeln(k);
  outans(pre[j]);
  writeln(v[j]);
end;

begin
  //assign(input,'in');reset(input);
  readln(n);
  if n=0 then begin
   writeln(0);
   halt;
  end;
  for i:=1 to n do begin
   readln(p[i].x,p[i].y);
   if p[i].x>p[i].y then begin
      j:=p[i].x;
      p[i].x:=p[i].y;
      p[i].y:=j;
   end;
  end;
  init;
  dynamic;
end.
You can't be WA lol
Posted by uuuuuuu 12 May 2003 11:48
I also thought it right,but it doesn't work!Could anyone who can find my bugs?
Posted by ufx 13 May 2003 16:20
>
LOL >> I meant you can't personally be Wrong Answer because it's a thing.... :D
Posted by uuuuuuu 14 May 2003 21:18
> >
could you explain? tell me about it .thanks.
Posted by ufx 16 May 2003 11:25
> > >
you should do it as 1203
Posted by ural_li yubo 18 May 2003 19:08
> > > >