比赛 20120224 评测结果 EEEEEEEEEE
题目名称 课程安排问题 最终得分 0
用户昵称 wo shi 刘畅 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2012-02-24 19:16:55
显示代码纯文本
var
  n,m,i,j,k,y:longint;
  v:array[0..10000]of boolean;
  now:boolean;
  g:array[0..200,0..200]of boolean;
  ru:array[0..10000]of longint;

begin
  assign(input,'curriculm.in'); reset(input);
  assign(output,'curriculm.out'); rewrite(output);
  readln(n);
  for i:=1 to n do
  begin
    read(m);
    for j:=1 to m do
    begin
      read(y);
      g[y,i]:=true;
      inc(ru[i]);
    end;
  end;
  for i:=1 to n do v[i]:=true;
  for j:=1 to n do
  begin
    now:=false;
    for i:=1 to n do
    if (ru[i]=0)and(v[i]) then
    begin
      write(i,' ');
      v[i]:=false;
      for k:=1 to n do
      if g[i,k] then
      begin
        g[i,k]:=false;
        dec(ru[k]);
      end;
      now:=true;
      break;
    end;
    if not now then
    begin
      writeln('no');
      close(input);
      close(output);
      halt;
    end;
  end;
  writeln;
  close(input);
  close(output);
end.