记录编号 15556 评测结果 AAAWAAAAAA
题目名称 学生成绩管理系统 最终得分 90
用户昵称 Gravatarybh 是否通过 未通过
代码语言 Pascal 运行时间 0.002 s
提交时间 2010-01-20 22:07:42 内存使用 0.18 MiB
显示代码纯文本
program linet;
var
  a1,a2,next:array[0..3000] of integer;
  b:array[0..3000] of boolean;
  i,j,n,n1,m,p,p1,s,s1,r1,r2,r3:integer;

begin
  assign(input,'linet.in');
  reset(input);
  assign(output,'linet.out');
  rewrite(output);
  readln(n);
  fillchar(b,sizeof(b),false);
  for i:=1 to n do
  begin
    readln(a1[i],a2[i]);
    b[a1[i]]:=true;
    next[i]:=i+1;
  end;
  next[0]:=1;
  next[n]:=0;
  readln(m);
  n1:=n;

  for i:=1 to m do
  begin
    read(s);

    if s=1 then
    begin
      read(s1);
      if s1=1 then
      begin
        read(r1);
        if b[r1] then
        begin
          for j:=1 to n do
            if r1=a1[j] then
            begin
              writeln(a1[j],' ',a2[j]);
              break
            end
        end
        else
          writeln('no');
      end;
      if s1=0 then
      begin
        if n1>=1 then
        begin
          p:=0;
          writeln(n1);
          while next[p]>0 do
          begin
            p:=next[p];
            writeln(a1[p],' ',a2[p])
          end
        end
        else
          writeln('no')
      end;
    end;

    if s=2 then
    begin
      read(s1);
      for j:=1 to s1 do
      begin
        read(r1,r2,r3);
        inc(r1);
        if n1<2000 then
        begin
          if b[r2]=false then
          begin
            inc(n);
            inc(n1);
            a1[n]:=r2;
            a2[n]:=r3;
            p:=0;
            p1:=0;
            while (next[p]>0) and (p1<=r1) do
            begin
              inc(p1);
              if p1=r1 then
              begin
                next[n]:=next[p];
                next[p]:=n;
              end;
              p:=next[p];
              if (next[p]=0) and (p1+1=r1) then
              begin
                next[p]:=n;
                next[n]:=0;
                break
              end
            end
          end
          else
            writeln('dup')
        end
        else
          writeln('out')
      end
    end;

    if s=3 then
    begin
      read(s1);
      for j:=1 to s1 do
      begin
        read(r1);
        if b[r1] then
        begin
          p:=0;
          while next[p]>0 do
          begin
            p1:=p;
            p:=next[p];
            if a1[p]=r1 then
            begin
              next[p1]:=next[p];
              dec(n1);
              break
            end
          end;
        end
        else
          writeln('error')
      end
    end;

    readln
  end;
  close(input);
  close(output)
end.