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

WA2 Help!
Posted by Rabidstorm 7 Apr 2009 19:30
program Ural1078;

var
  ok:array[1..500,1..500]of boolean;
  x,y,ans:array[1..500]of longint;
  a,b,n,max:longint;

function dfs(o,l:longint):boolean;

var
  i:longint;
  u:boolean;

begin
  u:=false;
  for i:=1 to n do
    if ok[o,i] then u:=u or dfs(i,l+1);
  if max<l then begin
    max:=l;
    u:=true;
  end;
  if u then ans[l]:=o;
  exit(u);
end;

begin
  readln(n);
  fillchar(ok,sizeof(ok),false);
  for a:=1 to n do
    readln(x[a],y[a]);
  for a:=1 to n do
    for b:=1 to n do
      if (x[a]<=x[b])and(y[b]<y[a]) then ok[a,b]:=true;
  max:=0;
  for a:=1 to n do
    if dfs(a,1) then ans[1]:=a;
  writeln(max);
  for a:=max downto 1 do
    write(ans[a],' ');
end.

What is wrong???