Please, help! What's Wrong with my solution!
Послано
1 1 июн 2003 22:08
const
nmax=500;
type
s=array[-1..nmax] of integer;
s1=array[1..2] of integer;
var
n:integer;
a:array[1..nmax] of s;
i,j,k,min,max:integer;
M:array[1..nmax] of s1;
b:array[1..nmax] of integer;
procedure init;
begin
fillchar(a,sizeof(a),0);
fillchar(b,sizeof(b),0);
readln(n);
for i:=1 to n do
begin
readln(m[i,1],m[i,2]);
if m[i,1]>m[i,2] then begin
j:=m[i,1];
m[i,1]:=m[i,2];
m[i,2]:=j; end;
end;
end;
function online(x,y:integer):boolean; {x in y}
begin
if ((m[y,1]<m[x,1]) and (m[x,2]<m[y,2])) and (m[x,1]<>m[x,2]) then
online:=true
else online:=false;
end;
procedure check(k:integer);
var i:integer;
begin
for i:=1 to n do
if online(k,i) then
begin
a[i,k]:=1;
a[k,i]:=1;
if a[k,-1]<=a[i,-1] then
a[k,-1]:=a[i,-1]+1;
end;
end;
function find:integer;
var max:integer;
i:integer;
begin
max:=1;
for i:=2 to n do
if a[max,-1]<a[i,-1] then max:=i;
find:=max;
end;
procedure print(k:integer);
var
s:integer;
begin
s:=1;
if a[k,-1]=0 then begin
writeln(k);
halt;
end;
for i:=1 to n do
if a[i,k]=1 then
begin
if a[i,-1]=a[k,-1]-1 then begin write(k,' '); print
(i);exit;end;
end;
end;
begin
init;
for i:=1 to n do check(i);
writeln(a[find,-1]+1);
i:=find;
print(i);
end.