显示代码纯文本
program pk;
var i,j,k,n,m,ans,x,y:longint;
can:boolean;
v:array[1..100,1..100]of boolean;
procedure init;
begin
assign(input,'contest.in');
reset(input);
assign(output,'contest.out');
rewrite(output);
readln(n,m);
fillchar(v,sizeof(v),0);
for i:=1 to m do
begin
readln(x,y);
v[x,y]:=true;
end;
end;
procedure main;
begin
for k:=1 to n do
for i:=1 to n do
for j:=1 to n do
v[i,j]:=(v[i,j])or(v[i,k] and v[k,j]);
for i:=1 to n do
begin
can:=true;
for j:=1 to n do
if (i<>j)and(not v[i,j])and(not v[j,i]) then can:=false;
if can then inc(ans);
end;
writeln(ans);
end;
procedure closef;
begin
close(input);
close(output);
end;
begin
init;
main;
closef;
end.