我用倒推法做的,第一次80分,然后修改了寻址顺序就成了100分了。。。
var s:set of 1..255;
n,m,i,j,k,l,p1:integer;
begin
readln(n,m);
for i:=1 to n do
begin
read(p1);
for j:=1 to p1 do begin read(k);s:=s+[k];end;
end;
for i:=1 to 255 do if i in s then l:=l+1;
if l>n then write(n) else write(l);
end.
g:array [1..100,0..300] of longint;
f,use:array [1..300] of boolean;
link:array [1..300] of longint;
function find(k:longint):boolean;
var i:longint;
begin
for i:=1 to g[k,0] do
if not(use[g[k,i]]) then
begin
use[g[k,i]]:=true;
if (link[g[k,i]]=0) or find(link[g[k,i]]) then
begin
link[g[k,i]]:=k;
exit(true);
end;
end;
exit(false);
end;
begin
read(n,m);
for i:=1 to n do
begin
read(g[i,0]);
fillchar(f,sizeof(f),false);
for j:=1 to g[i,0] do
begin
read(x);
f[x]:=true;
end;
x:=0;
for j:=1 to m do
if f[j] then
begin
x:=x+1;
g[i,x]:=j;
end;
end;
ans:=0;
fillchar(link,sizeof(link),0);
for i:=1 to n do
begin
fillchar(use,sizeof(use),false);
if find(i) then
inc(ans);
end;
writeln(ans);
end.