记录编号 |
138481 |
评测结果 |
AAAAAATAAA |
题目名称 |
[NOIP 2013]车站分级 |
最终得分 |
90 |
用户昵称 |
铁策 |
是否通过 |
未通过 |
代码语言 |
Pascal |
运行时间 |
1.553 s |
提交时间 |
2014-11-05 21:29:00 |
内存使用 |
4.13 MiB |
显示代码纯文本
program P1444;
uses math;
var
i,j,k,l,m,n,sum,o:longint;
a,b,c,check:array[0..1000] of longint;
p:array[0..1000,0..1000] of longint;
procedure outp(x:longint);
var
i:longint;
begin
for i:=1 to n do if p[x,i]=1 then begin p[x,i]:=0; dec(check[i]); end;
end;
begin
assign(input,'level2013.in');
reset(input);
assign(output,'level2013.out');
rewrite(output);
readln(n,m);
for i:=1 to m do
begin
read(a[i]);
fillchar(c,sizeof(c),0);
for j:=1 to a[i] do
begin
read(b[j]);
c[b[j]]:=1;
end;
readln;
for o:=b[1] to b[a[i]] do
if c[o]=0 then
for j:=1 to a[i] do
p[b[j],o]:=1;
end;
for i:=1 to n do
for j:=1 to n do
inc(check[i],p[j,i]);
fillchar(b,sizeof(b),0);
while true do
begin
fillchar(c,sizeof(c),0);
k:=0;
for i:=1 to n do
if (b[i]=0)and(check[i]=0) then
begin
inc(k);
c[k]:=i;
b[i]:=1;
end;
for i:=1 to k do
outp(c[i]);
inc(sum);
if k=0 then break;
end;
writeln(sum-1);
close(input);
close(output);
end.